Div= Operator

Divides the value of a variable by the value of an expression, then changes the variable to the result, if the expression is not zero. If the expression is zero, then the variable becomes zero.


variable Div= expression


A numeric variable or property.
A numeric expression.


The two statements that follow operate the same.

variable Div= expression
variable = variable Div expression

The element on the left side of Div= can be a scalar variable, a property, or an element of an array. If it is a property, then it cannot have the modifier @ReadOnly.

Div= divides the variable or property on its left side by the value on its right side to get a quotient. If the value of the right side is not zero, then it changes the variable or property on its left side to the quotient. But if the value on the right side is zero, then it changes the variable to zero.

Div= is an alternative to /=. /= can cause an exception for some values. But you can use Div= where you can safely ignore the result of division by zero.

Data types



x = 84
x Div= 2
y = x
y Div= 0
After execution

See also