Skip to main content

/ operator

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

Used to divide two numbers and return a floating-point result.

Syntax

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.

Remarks

The data type of result is usually a Double or a Double variant. The following are exceptions to this rule:

If Then result is
Both expressions are Byte, Integer, or Single expressions A Single unless it overflows its legal range, in which case, an error occurs.
Both expressions are Byte, Integer, or Single variants A Single variant unless it overflows its legal range, in which case, result is a Variant containing a Double.
Division involves a Decimal and any other data type A Decimal data type.

If one or both expressions are Null expressions, result is Null. Any expression that is Empty is treated as 0.

Example

This example uses the / operator to perform floating-point division.

Dim MyValue
MyValue = 10 / 4   ' Returns 2.5.
MyValue = 10 / 3   ' Returns 3.333333.

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>