Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Using the Mod Operator

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Mod operator divides two numbers and returns the remainder. It's useful when you need to determine whether two numbers divide evenly, or how close they come to dividing evenly. The Mod operator always returns an Integer or Long value, even when you divide floating-point or fixed-point numbers.

For example, the IsFactor procedure takes two arguments, a number and a potential factor, and returns True if the second argument is indeed a factor of the first. The procedure uses the Mod operator to determine whether one value divides evenly into the other.

Function IsFactor(lngNum As Long, _
                lngFactor As Long) As Boolean
            
   ' Determines whether one number is a factor of another number.
   
   IsFactor = Not CBool(lngNum Mod lngFactor)
End Function

The IsFactor procedure is available in the modNumbers module in VBA.mdb in the ODETools\V9\Samples\OPG\Samples\CH07 subfolder on the Office 2000 Developer CD-ROM.

Show:
© 2015 Microsoft