Calculates the modulo of an integer expression based on a second integer expression.
Mod v, y( assignment)
% = i Mod j( operator)
% = Mod( i, j [,m,…] )( function)
v:any numeric variable
y:any number expression
i, j, m:integer expression
Mod v, y calculates the modulo of the value in variable v based on the expression y.
The operator i Mod j and the function Mod(i, j, …) return an integer value. In case one of the parameters isn't an integer, it is converted to a 32-bit value first (using CInt).
Debug.Show
Dim b As Double = 7.1, c%
Trace b Mod 3 // CInt(b) Mod 3 = 1
Trace Mod(b, 3) // CInt(b) Mod 3 = 1
Trace b : c% = b
' Mod Command requires an integer variable
Mod b, 3 : Trace b // b = 3 - NOT CORRECT
Mod c%, 3 : Trace c% // c% = 1 - CORRECT
b = 2
Trace b Mod 3.1 // CInt(b) + CInt(3.1) = 2
Trace Mod(b, 3) // CInt(b) + 3 = 2
Trace Mod(7, 4, 3) // 0
The Mod v, y assignment command doesn't work correctly when v is not an integer.
Add, Sub, Mul, Div, FMod, Dec, Inc, Pred, ++, --, +=, -=, /= , *=
{Created by Sjouke Hamstra; Last updated: 18/10/2014 by James Gaite}