contents.gifindex.gifprev1.gifnext1.gif

Mod Operator

Purpose

Divides two numbers and returns only the remainder.

Syntax

result = operand1 Mod operand2

Notes

The modulus, or remainder, operator divides operand1 by operand2 (rounding floating-point numbers to integers) and returns only the remainder as result. For instance, in the following example, A (which is result) equals 5:

A = 19 Mod 6.7

The operands can be any numeric expression. Usually, the data type of result is an Integer, a Long, or a Variant of VarType 2 (Integer) or VarType 3 (Long). However, result is a Null (VarType 1) if one or both operands are Null expressions. Any operand that is Empty (VarType 0) is treated as 0.

Example

This example determines the remainder after 100,000 units are divided among seven people using integer division and returns 5.

X = 100000 Mod 7