|
-
Aug 2nd, 2005, 10:55 PM
#1
Thread Starter
Hyperactive Member
Moving decimal
I am getting value of 40836.0 generating from another program. Now I wanted to move decimal at -3, turning it into 40.8. How do I do this with code?
I tried divididng by 1000 and I get round off to 41.0... Actually I want precise number "40.8. Anyone?
-
Aug 2nd, 2005, 11:48 PM
#2
Lively Member
Re: Moving decimal
Do you have the variable defined as an Integer or as a double or single?
Despite body and mind, my youth will never die!
Everytime I learn something new it pushes some old stuff out of my brain!
-
Aug 2nd, 2005, 11:59 PM
#3
Re: Moving decimal
This works for me
VB Code:
Option Explicit
Private Sub Form_Load()
Dim a As Long
Dim b As Currency
a = 40836
b = a / 1000
MsgBox Format(b, "###.#")
End Sub
prints 40.8
-
Aug 3rd, 2005, 12:05 AM
#4
Thread Starter
Hyperactive Member
-
Aug 3rd, 2005, 12:06 AM
#5
Re: Moving decimal
Refresh your screen. I posted #3 a few minutes ago.
-
Aug 3rd, 2005, 12:07 AM
#6
Lively Member
Re: Moving decimal
As dglienna said,
Number divided by 1000 formated to show 1 decimal place will work. You have to check if there is something in you code that is rounding your number.
Despite body and mind, my youth will never die!
Everytime I learn something new it pushes some old stuff out of my brain!
-
Aug 3rd, 2005, 03:00 AM
#7
Re: Moving decimal
High Octane
This is what you want.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim a As Long
Dim b As Currency
a = 40836
b = CCur(a / 1000)
MsgBox Format(b, "###.#")
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|