hey i need to know how to get a value with 2 decimals..
i tried with e.g a = 3.102 round ( a,2) i get the value as 3.1 and not as 3.10...i want to get the value as 3.10 ..how can i make it..??
Printable View
hey i need to know how to get a value with 2 decimals..
i tried with e.g a = 3.102 round ( a,2) i get the value as 3.1 and not as 3.10...i want to get the value as 3.10 ..how can i make it..??
to show leading or trailing zeroes you must display the value as a string, using format command
Or you could format the cells with a number format. If you need the value to actually round because you are going to perform operations with it then use the formula you posted and format the cell as number. But if you only need it to display with 2 decimals and do not care if the actual value has more precision then just format the cell and leave the number as is.
hey leave off excel...i am using MicroStation (a drafting software for Mech Engineers ). I actually want a VB code.
a= 3.100
b=round(a,2)
msgbox(b)
I should get the value in msgbox as 3.10
now what shall i do....I can't use any excel worksheet functions here ...
i tried with this Math.Round (3.102, 2) but still i din get desired result :( :(
b = Format(Round(3.102, 2), "#0.00")
Thank You Guys this works fine
AFAIK this is the correct forum for all vba and other application automatingQuote:
Then you posted in the wrong forum
you do not need to round the number, if you only need the 2 digit decimal for display purposes, the format will do thatQuote:
b = Format(Round(3.102, 2), "#0.00")
round returns a value,
format returns a string
oh fine....but if i need the value of 3.167 as 3.17 will the format function round it's value...??? i suppose it just displays the result as 3.16
correct, in your case you need Round and Format. Format since you need a display of "3.00"!