Click to See Complete Forum and Search --> : Converting to percentage


WoG
12-07-2004, 03:23 PM
I want to make a calculation on two numbers, (divide one into another) and display the result with the following format:
##.##%

Here is what I have for the calculation:
LAS_diff_perc = CInt(LAS_diff)/CInt(LASprev)
Response.Write (LAS_diff_perc)

Obviously, I get something like this:
0.612903225806452

How do I get the result with only 2 decimals past the decimal point?

Thanks!

russell
12-07-2004, 06:14 PM
LAS_diff_perc = FormatNumber(CInt(LAS_diff)/CInt(LASprev), 2)


FormatNumber() Function (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctFormatNumber.asp)

russell
12-07-2004, 06:16 PM
oh yeah, and to make it a percentage (45% as opposed to 0.45) multiply by 100