wzm
asked on
VB6
Hi,
How to use format to chop off the long trail decimal without rounding (up and down ) it and up to 2 decimals only?
e.g - 343.236788976
to be 343.23 NOT 343.24
TQ!.
How to use format to chop off the long trail decimal without rounding (up and down ) it and up to 2 decimals only?
e.g - 343.236788976
to be 343.23 NOT 343.24
TQ!.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would use:
Dim strResult As String
strResult = Format(dblValue, "#0.000")
strResult = Left(strResult, Len(strResult) - 1)
Another possibility would be:
Format(Fix(100 * Value) / 100, "#0.00")
"Fix" returns the integer equal to or closer to zero than the argument. Depending on how you want to deal with negative numbers you might want to use "Int" instead of "Fix". "Int" returns the integer less than or equal to the argument. (The above will "truncate" -123.456 to -123.45 whereas if "Int" is used it will return -123.46.)
Cheers,
Randy