decimal calculation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?a2FyaW0=?=

    decimal calculation

    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.
  • =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=

    #2
    Re: decimal calculation

    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.ToDoubl e(steps) * 0.01
    fieldMiles.Text = miles.ToString( "#.0")

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    Working...