This section provides some detail rules and a tutorial example on how arithmetic integer division operation works in VBScript.
Here are some detail rules about the arithmetic operation - integer division:
Arithmetic integer division operation uses the integer division operator: "\"
Arithmetic integer division operation requires that at least one of the operands is a numeric subtype:
Byte, Integer, Long, Single or Double.
If an operand is not a numeric subtype, it will be converted into a numeric subtype.
If an operand is not an integer, it will be rounded into an integer.
If the rounding process fails, the whole operation will fail.
The Boolean subtype is considered as a numeric subtype in an integer division operation.
"True" represents a numeric value of -1. "False" represents a numeric value of 0.
The Empty subtype is considered as a numeric subtype in an integer division operation.
"Empty" represents a numeric value of 0.
When a String value is used in an integer division operation, it will be parsed into a Long value.
If the parsing process fails, the integer division operation will raise the "Type mismatch" runtime error.
The operation will fail, if the second operand is a 0. Dividing by 0 is mathematically impossible.
The returning value is the result of the first operand divided by the second operand with the decimal fraction part removed from the result.
The subtype of the returning value is Integer or Long determined by the returning value range and subtypes of operands.
Here is a tutorial example showing you how arithmetic integer division operation rules work: