Board index » Visual Studio » Help with getting the correct number format

Help with getting the correct number format

Visual Studio229
I'm having trouble returning a number in the proper format with the code I

have. I want to take a number, like 9.16, multiple the ".16" by .6 then

return the results in a ##.## format. What I'm getting is 9.36, I'd like

it to return 09.36. Basically, I need the '0' when there is only one digit

before the decimal point. Here's what I have:



dectomin = Format(dectomin, " ##.##")

dectomin = Right(frmMoon!Text1.Text, 2) * 0.6

txtDecMin.Text = Left(Format(dectomin, "##"), 2)



What am I doing wrong?



Thanks!

Chuck


-
 

Re:Help with getting the correct number format

Thanks Rick, that was it.



chuck



"Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net>wrote in message

Quote
>I'm having trouble returning a number in the proper format with the code

I

>have. I want to take a number, like 9.16, multiple the ".16" by .6 then

>return the results in a ##.## format. What I'm getting is 9.36, I'd

like

>it to return 09.36. Basically, I need the '0' when there is only one

digit

>before the decimal point. Here's what I have:

>

>dectomin = Format(dectomin, " ##.##")

>dectomin = Right(frmMoon!Text1.Text, 2) * 0.6

>txtDecMin.Text = Left(Format(dectomin, "##"), 2)

>

>What am I doing wrong?



I'm not really following what you are doing calculation-wise, but to

preserve leading zeroes on a String (or for display), use 0 (zero) not #

(number sign) in the Format statement.



Rick - MVP









-