Formatting decimal variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Formatting decimal variable

    Try
    myString = myDecimal.ToStr ing("g3");
    3 is significant number
    [color=blue]
    >-----Original Message-----
    >When formatting a decimal variable, is there a format
    >string that will show decimals only when they are non-[/color]
    zero?[color=blue]
    >
    >For example, I would like the following values to be
    >converted to strings like this:
    >
    > 1 = 1
    > 1.7 = 1.7
    > 1.25 = 1.25
    >
    >If I use
    >
    >myString = myDecimal.ToStr ing("n2");
    >
    >I get
    >
    > 1 = 1.00
    > 1.7 = 1.70
    > 1.25 = 1.25
    >
    >and if I use
    >
    >myString = myDecimal.ToStr ing("n0");
    >
    >I get
    >
    > 1 = 1
    > 1.7 = 2
    > 1.25 = 1
    >
    >Neither of these is quite what I'm after.
    >
    >Thanks,
    >Ric
    >
    >.
    >[/color]
Working...