954,558 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with decimal places

The following code comes up with a number that has 13 digits past the decimal point. How can I cut this down to 2 decimal places?

[Let drivetimeexpense = (rstdrivinginfo.timefromhome * rstdrivinginfo.numberoftrips * 2 / 60) * 20]

stan yost
Light Poster
29 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

Where do you want it cut down? For display, many things such as texboxes have a way to number format data.

Then there's the Format function.
http://www.samspublishing.com/library/content.asp?b=STY_VB6_24hours&seqNum=154&rl=1

As a very last resort, you basically multiple the number by 100, truncate to int, then divide by 100. But that's VERY old school, and assumes for some reason you don't have any of the normal string and number formatting functions available.

nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
 

Where do you want it cut down? For display, many things such as texboxes have a way to number format data.

Then there's the Format function. http://www.samspublishing.com/library/content.asp?b=STY_VB6_24hours&seqNum=154&rl=1

As a very last resort, you basically multiple the number by 100, truncate to int, then divide by 100. But that's VERY old school, and assumes for some reason you don't have any of the normal string and number formatting functions available.

Thanks!

stan yost
Light Poster
29 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You