Operator ModuloRight

From Xojo Documentation

Revision as of 19:11, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


Used to overload the Mod function, providing custom functionality.


Create an Operator_ModuloRight function in a class to specify the functionality of the Mod operator for that class. The instance of Self is on the right side of the Mod expression. The other instance is passed as a parameter.

The ordinary (left) methods are always preferred; REALbasic uses the Right version only if there is no legal left version.


Using the Vector class (see Operator_Add) with two Integer elements, x and y, we define an Operator_ModuloRight function that returns the remainder of the division of the sum of the Self instance by the passed instance.

Function Operator_ModuloRight (lhs as Vector) as Integer
Dim a, b as Integer
 a=Self.x + Self.y
 b=lhs.x + lhs.y

Return b Mod a

See Also

Mod operator; Operator_Modulo function.