|
-
Nov 7th, 2001, 07:42 AM
#1
Thread Starter
Member
Checking number of dec.places
with regards to a thread that I posted earlier dealing with rounding down - I found the following formula for achieving this :
tempcalc = int(tempcalc * 100 + 0.5) / 100
if tempcalc = 0.016 - u get 0.02
if tempcalc = 0.015 - u get 0.01
which is the result I wanted.
Further to this, how do I return just the decimal part of a double defined variable & know how many decimal places there are?
eg - if I have 12.000156
I just want to return 000156 without the dec.point & know that I have 6 figures.
-
Nov 7th, 2001, 07:45 AM
#2
-= B u g S l a y e r =-
VB Code:
Private Sub Command2_Click()
MsgBox Split(Str(12.000156), ".")(1)
End Sub
-
Nov 7th, 2001, 07:52 AM
#3
Thread Starter
Member
-
Nov 7th, 2001, 08:26 AM
#4
Conquistador
Um peet, wouldn't it be?
MsgBox Len(Split(Str(12.000156), ".")(1))
?
as he wants to know the number of decimal places, not all of them?
-
Nov 7th, 2001, 08:35 AM
#5
-= B u g S l a y e r =-
Originally posted by da_silvy
Um peet, wouldn't it be?
MsgBox Len(Split(Str(12.000156), ".")(1))
?
as he wants to know the number of decimal places, not all of them?
yes... I recon he wants that as well, but I think that he might have figured out the Len function 
to be honest... I only read the first part of the question. ..
I just want to return 000156 without the dec.point
 
is a better version with less white spots in the transp. area
-
Nov 7th, 2001, 08:37 AM
#6
Fanatic Member
How about adding this so you get a usable decimal
Code:
Dim Ans As Double
Ans = 12.000156 - (Int (12.000156))
-
Nov 7th, 2001, 08:40 AM
#7
-= B u g S l a y e r =-
Originally posted by steve65
How about adding this so you get a usable decimal
Code:
Dim Ans As Double
Ans = 12.000156 - (Int (12.000156))
thanks alot Steve 
now I feel really stupid *hrmpf*
-
Nov 7th, 2001, 08:59 AM
#8
Fanatic Member
No problem just remeber this day when I ask my next stupid question
-
Nov 7th, 2001, 03:15 PM
#9
Conquistador
Hehehehe,
If it's on VBA i'm set.
I've answered a few of them recently
-
Nov 7th, 2001, 03:20 PM
#10
Conquistador
Now, to answer his question 
VB Code:
Dim DecPlaces As Double
DecPlaces = Len(12.000156 - (Int (12.000156)))
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
|