Skip to main content

\ operator

Table of contents
  1. Syntax
  2. Remarks
  3. Example

Used to divide two numbers and return an integer result.


result = number1 \ number2

The \ operator syntax has these parts:

Part Description
result Required; any numeric variable.
number1 Required; any numeric expression.
number2 Required; any numeric expression.


Before division is performed, the numeric expressions are rounded to Byte, Integer, or Long expressions.

Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Long variant, regardless of whether result is a whole number.

Any fractional portion is truncated. However, if any expression is Null, result is Null. Any expression that is Empty is treated as 0.


This example uses the \ operator to perform integer division.

Dim MyValue
MyValue = 11 \ 4   ' Returns 2.
MyValue = 9 \ 3   ' Returns 3. 
MyValue = 100 \ 3   ' Returns 33.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>