How do i format a text box to display a number as two decimal places. Eg. number is 45.888888 and i want it displayed in the text box as 45.89
Thanks
Samantha
Printable View
How do i format a text box to display a number as two decimal places. Eg. number is 45.888888 and i want it displayed in the text box as 45.89
Thanks
Samantha
Text1.text = cstr(int(45.888888 *100)/100)
The more elegant way to do stuff like this it is to use the Format() and Round() functions, they are documented in the MSDN.
Round(45.888888,2)
I like the faster inline solution :p
Clair, If your username is clair, why did you sign the post with the name Samantha ?Quote:
Originally posted by Claire
How do i format a text box to display a number as two decimal places. Eg. number is 45.888888 and i want it displayed in the text box as 45.89
Thanks
Samantha
Just wondering :)
I can remember exactly what it was, but I am pretty sure there is a bug in the rounding function? :confused:Quote:
Originally posted by Active
Round(45.888888,2)
yeah i think i remember that too, btw, can you do something about your very long sig ?
Hi Plenderj
My friend Samantha was here with me at the time and she posted that question!
Claire.
I think Round will actually round it, whereas converting to an Integer through multiplying it by 100 will truncate it instead.
my mistake, should be
cstr(int(45.888888 *100+0.5)/100)
Sorry for the trouble :pQuote:
Originally posted by kedaman
yeah i think i remember that too, btw, can you do something about your very long sig ?
All gone now ;)
parksie ; love the avatar ;)
:D:p:D
:parksie: