Visual Basic Language Reference  

- Operator

Yields the difference between two numbers or indicates the negative value of a numeric expression.

Syntax 1

expression1 expression2

Syntax 2

number

Parts

number
Required. Any numeric expression.
number1
Required. Any numeric expression.
number2
Required. Any numeric expression.

Result

The result will be the difference between number1 and number2.

Supported Types

Byte, Short, Integer, Long, Single, Double, Decimal

Remarks

In Syntax 1, the operator is the arithmetic subtraction operator for the difference between two numbers. In Syntax 2, the operator is the unary negation operator for the negative value of an expression. The data type of the result is the same as that of the data type with the greatest range. The order of range, from least to greatest range, is Byte, Short, Integer, Long, Single, Double, and Decimal.

If an expression is stated as Nothing, it is treated as zero.

Example

This example uses the - operator to calculate and return the difference between two numbers.

Dim myResult As Double
myResult = 4 - 2   ' Returns 2.
myResult = 459.35 - 334.90   ' Returns 124.45.

See Also

-= Operator | Arithmetic Operators | Operator Precedence in Visual Basic | Operators Listed by Functionality | Arithmetic Operators