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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ Modulus?

Modulus?

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


Posted by Stoned00d   (14 posts)  Bio
Date Sat 09 Feb 2002 03:20 AM (UTC)
Message
Really sorry, but I never formally learned VB script, but I'm familiar with C++ and I was wondering if there is a modulus operation in VB? ie, 5%2=1 since the remainder of 5 divided by 2 is 1.
Top

Posted by Mademoiselle   Australia  (35 posts)  Bio
Date Reply #1 on Sat 09 Feb 2002 03:26 AM (UTC)
Message
Yup, I do believe so. Use the "mod" command, I think in the same manner as you'd use the % symbol in C/c++.

Print 10 Mod 3
1

If that doesn't work, perhaps it's implemented as a function Mod()?

Best of luck.
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #2 on Sun 10 Feb 2002 09:47 AM (UTC)
Message
This is correct. I looked it up to be sure. Of course 'print' is not actually a command under vbscript, but then you probably quessed that. ;)

As a side note (and rant) I definitely miss 'print using', since vbscript support special formating for currency and other things, but for some idiotic reason does not provide support for the automatic padding that was possible with the Print Using command. :p I hate being forced to do things the hard way, especially since the hard way involves creating possible errors if the length of the converted value ever exceeds the number of spaces available. You end up having to -

A) Convert it to a string.
B) Find the length.
C) Subtract the result from some number.
D) Check to make sure the result is bigger than 0.
E) Print the correct number of spaces.
F) Finally print the dang number.

This was a basic built in feature of most forms of Basic for years, now we have to do it ourselves. :p This is not C after all. lol
Top

Posted by Stoned00d   (14 posts)  Bio
Date Reply #3 on Sun 10 Feb 2002 04:25 PM (UTC)
Message
thanks! I was trying to use the % operator and it was giving me errors!
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.


18,326 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.