944,221 Members | Top Members by Rank

Ad:
Jan 3rd, 2007
0

problem with decimal places

Expand Post »
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]
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
stan yost is offline Offline
29 posts
since Aug 2006
Jan 3rd, 2007
1

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.
Reputation Points: 13
Solved Threads: 4
Junior Poster in Training
nikkiH is offline Offline
79 posts
since Dec 2006
Jan 3rd, 2007
0

Re: problem with decimal places

Click to Expand / Collapse  Quote originally posted by nikkiH ...
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!
Reputation Points: 10
Solved Threads: 0
Light Poster
stan yost is offline Offline
29 posts
since Aug 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: problem with mscomm
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: gamepad in vb?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC