[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  rounding off decimal places
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

rounding off decimal places

It is now over 60 days since the last post. This thread is closed.     [Refresh] 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?
[Go to top] 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
[Go to top] 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)
[Go to top] top

Posted by Vaejor   (120 posts)  [Biography] 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
[Go to top] 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.


15,789 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]