result = number1–number2
–number
The – operator syntax has these parts:
In Syntax 1, the – operator is the arithmetic subtraction operator used to find the difference between two numbers. In Syntax 2, the – operator is used as the unary negation operator to indicate the negative value of an expression.
The data type of result is usually the same as that of the most precise expression. The order of precision, from least to most precise, is Byte, Short Integer, Long, Single, Double, and Decimal. The following are exceptions to this order: If | Then result is |
---|---|
Subtraction involves a Single and a Long, | converted to a Double. |
The data type of result is a Long, or Single, that overflows its legal range, | A Run-time error will occur. |
The data type of result is a Byte object that overflows its legal range, | A Run-time error will occur. |
The data type of result is an Integer object that overflows its legal range, | A Run-time error will occur. |
One or both expressions arestated as Nothing, a Variable Not Set
error occurs. If an expression is Empty, it is treated as 0.
Note The order of precision used by addition and subtraction is not the same as the order of precision used by multiplication.
-= Operator | Arithmetic Operators | Operator Precedence in Visual Basic | Operator Summary