Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ VBscript ➜ rounding off decimal places

rounding off decimal places

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Guest1   USA  (256 posts)
Date Tue 01 Oct 2002 08:20 AM (UTC)
Message
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?
Top

Posted by Guest1   USA  (256 posts)
Date Reply #1 on Tue 01 Oct 2002 09:11 AM (UTC)
Message
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
Top

Posted by Guest1   USA  (256 posts)
Date Reply #2 on Tue 01 Oct 2002 09:21 AM (UTC)
Message
found it :)

percent = Round(exp / explevel * 100, 2)
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #3 on Tue 01 Oct 2002 01:39 PM (UTC)
Message
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctformatpercent.asp
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


25,996 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.