contents.gifindex.gifprev1.gifnext1.gif

- Operator

Purpose

Used to find the difference between two numbers or to indicate the negative value of an operand.

Syntax 1

result = operand1 - operand2

Syntax 2

-number

Notes

In Syntax 1, the - operator is the arithmetic subtraction operator used to find the difference between two numbers. The operands can be any numeric expression.

The data type of result is usually the same as that of the most precise operand. The order of precision, from least to most precise, is Integer, Long, Single, Double, Currency. When the operands are Variant expressions, the following rules supersede this order:

traxhelp00090000.gif When subtraction involves a Single and a Long, the data type of result is converted to a Double.

traxhelp00090000.gif When the data type of result is a Variant of VarType 3 (Long), VarType 4 (Single), or VarType 7 (Date) that overflows its legal range, result is converted to a Variant of VarType 5 (Double).

traxhelp00090000.gif When the data type of result is a Variant of VarType 2 (Integer) that overflows its legal range, result is converted to a Variant of VarType 3 (Long).

If one or both operands are Null expressions, result is a Null. If an operand is Empty (VarType 0), it is treated as if it were 0.

In Syntax 2, the - operator is used as the unary negation operator to indicate the negative value of an operand. As with Syntax 1, the operand can be any numeric constant, variable, or expression or any function that returns a number.

Example Syntax 1

This example determines net pay by using the - operator to subtract the total of state and federal taxes from gross pay. After the calculation, NetPay equals 8200.

GrossPay = 10000
// Assign gross pay.
StateTax = .06 * GrossPay
// Calculate state tax.
FederalTax = .12 * GrossPay
// Calculate federal tax.
TotalTax = StateTax + FederalTax
// Calculate total tax.
NetPay = GrossPay - TotalTax
// Calculate net pay.
Example Syntax 2

This example uses the - operator to indicate a negative value.

-1200.55