Export (0) Print
Expand All
Expand Minimize
4 out of 5 rated this helpful - Rate this topic

Converting VBScript's Mod Operator


Windows PowerShell


Definition: Divides two numbers and returns only the remainder.

Mod

The Mod operator is a bit of an odd duck (although it does have its uses): it divides two numbers and then returns the remainder. In Windows PowerShell you can achieve the same effect by using the % operator. For example, this command divides 28 by 5, then stores the remainder in the variable $a:



$a = 28 % 5

When you run this command and then echo back the value of $a you should get the following:



3


Return to the VBScript to Windows PowerShell home page

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.