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.
Modulus?
Posted by Stoned00d on Sat 09 Feb 2002 03:20 AM — 4 posts, 20,123 views.
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.
Print 10 Mod 3
1
If that doesn't work, perhaps it's implemented as a function Mod()?
Best of luck.
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
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
thanks! I was trying to use the % operator and it was giving me errors!