Method

# Operator_Modulo

<div class="rst-class">

forsearch

</div>

Operator

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to overload the `Mod</api/language/operators/mathematical/mod>` function, providing custom functionality.

## Notes

Create an <span class="title-ref">Operator_Modulo</span> function in a class to specify the functionality of the `Mod</api/language/operators/mathematical/mod>` operator for that class.

In the function, the `Self</api/language/self_keyword>` instance the left operand and the other operand is passed as a parameter.

## Sample code

Using the Vector class (see `Operator Add</api/language/operators/operator_overloads/operator_add>`) with two `Integer</api/data_types/integer>` elements, x and y, we define an <span class="title-ref">Operator_Modulo</span> function that returns the remainder of the division of the sum of the `Self</api/language/self_keyword>` instance by the passed instance.

``` xojo
Function Operator_Modulo(rhs As Vector) As Integer
  Var a, b As Integer
  a = Self.x + Self.y
  b = rhs.x + rhs.y

  Return a Mod b
End Function
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Mod</api/language/operators/mathematical/mod>` operator; `Operator ModuloRight</api/language/operators/operator_overloads/operator_moduloright>` function.

</div>
