You could use the ([number]).ToString([number formatting expression]) like
so:
Dim TestNumber as Double = 1.2345
Dim strNumber as String
strNumber = TestNumber.ToString("#.00000")
'strNumber = "1.23450"
strNumber = TestNumber.ToString("#.00")
'strNumber = "1.23"
strNumber = TestNumber.ToString("00.#")
'strNumber = "01.2345"
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
Danny Woolston <da*************@farmade.com> wrote: I have a property of a control which will return a double, but the
control allows the user to return a number of decimal places.
So if the decimal places are set to 2 and the number stored is 1.021
then on a call to the number property i want returned 1.02, or if the the number
stored is 1.3 and a decimal place of 3 then i want returned 1.300.
Let me stress that this is number only property i cannot use the format
property of the string.
Well you've got to - because doubles themselves don't *have* a number
of decimal places, they just have values. You can round a double to the
extent that rounding 1.021 to 2DP will round it to the closest double
value to 1.02, but there's no difference in the double itself between
1.5 and 1.50.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too