User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 401,946 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,368 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 2438 | Replies: 2 | Solved
Reply
Join Date: Aug 2006
Posts: 27
Reputation: stan yost is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
stan yost stan yost is offline Offline
Light Poster

Help problem with decimal places

  #1  
Jan 3rd, 2007
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]
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2006
Location: Near Chicago
Posts: 79
Reputation: nikkiH is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
nikkiH's Avatar
nikkiH nikkiH is offline Offline
Junior Poster in Training

Re: problem with decimal places

  #2  
Jan 3rd, 2007
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.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Reply With Quote  
Join Date: Aug 2006
Posts: 27
Reputation: stan yost is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
stan yost stan yost is offline Offline
Light Poster

Re: problem with decimal places

  #3  
Jan 3rd, 2007
Originally Posted by nikkiH View Post
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!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 5:21 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC