DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   problem with decimal places (http://www.daniweb.com/forums/thread66320.html)

stan yost Jan 3rd, 2007 5:14 pm
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]

nikkiH Jan 3rd, 2007 5:46 pm
Re: problem with decimal places
 
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/librar...eqNum=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.

stan yost Jan 3rd, 2007 7:49 pm
Re: problem with decimal places
 
Quote:

Originally Posted by nikkiH (Post 296490)
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/librar...eqNum=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!


All times are GMT -4. The time now is 6:48 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC