rounding off decimal places

Posted by Guest1 on Tue 01 Oct 2002 08:20 AM — 4 posts, 30,324 views.

USA #0
hopefully this is something easy.. i have a reporter to show how much i have completed in attaining a level (shows as a percentage) - very basic subroutine:

sub expreport (strTriggerName, trig_line, arrWildCards)
dim exp
dim explevel
dim percent
exp = World.GetVariable("exp")
explevel = World.GetVariable("explevel")
percent = exp / explevel * 100
world.EchoInput = 0
World.send "grouptell unused exp : " & exp & ". level completed : " & percent & "%\a01"
world.EchoInput = 1
end sub

where the exp variable = unused experience points so far, and explevel variable = exp points required for next level. No worries there. All i'm wanting is to have the % result display to only 2 deciaml places, not 7 or so like it is most of the time now.. Anyone able to guide me with this?
USA #1
add on:

the only thing I have discovered so far is to change this line in the routine to

percent = cint(exp / explevel * 100)

which rounds it to whole digits, but still looking for the syntax to make it to 2 decimal places.. it must exist somewhere.. if I find it first I'll post again here
USA #2
found it :)

percent = Round(exp / explevel * 100, 2)
#3
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctformatpercent.asp