PC Review


Reply
Thread Tools Rate Thread

decimal calculation

 
 
karim
Guest
Posts: n/a
 
      20th Oct 2008
Hello All,
my question is how to get a text box or a label to display decimal
#, like 0.9 or 1.4.
what i'm trying to do is to convert from, for example, steps to miles. if 1
mile = 2000 steps, then if i put anything less than 2000 it show as a zero
(0). so how do i get it to be .#(point something)?
Thanks for all your help.
 
Reply With Quote
 
 
 
 
Göran Andersson
Guest
Posts: n/a
 
      20th Oct 2008
karim wrote:
> Hello All,
> my question is how to get a text box or a label to display decimal
> #, like 0.9 or 1.4.
> what i'm trying to do is to convert from, for example, steps to miles. if 1
> mile = 2000 steps, then if i put anything less than 2000 it show as a zero
> (0). so how do i get it to be .#(point something)?
> Thanks for all your help.


You need to use floating point variables to do the calculation. Example:

Dim miles As Double = Convert.ToDouble(steps) * 0.01
fieldMiles.Text = miles.ToString("#.0")

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculation with Decimal Cmenkedi Microsoft Excel Worksheet Functions 5 4th Jan 2008 12:07 AM
Calculation/ decimal problem =?Utf-8?B?Qm9ubmll?= Microsoft Access Macros 4 30th Mar 2007 10:38 PM
problem with decimal in calculation =?Utf-8?B?QW1hbmRh?= Microsoft Excel Misc 5 12th Jan 2006 06:25 PM
SQL SUM calculation decimal?? ed Microsoft Access Forms 2 25th Mar 2004 06:38 PM
calculation decimal limit txfirepro Microsoft Excel Worksheet Functions 1 16th Mar 2004 08:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:25 AM.