+ operator

+ operator

Used to sum two numbers.

Syntax

result = expression1+expression2

The + operator syntax has these parts:

Part Description
result Any numeric variable.
expression1 Any expression.
expression2 Any expression.

Remarks

Use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.

When you use the + operator, you may not be able to determine whether addition or string concatenation will occur. If at least one expression is not a Variant, the following rules apply:

Operation performed If
Add Both expressions are numeric data types (Byte, Boolean, Integer, Long, Single, Double, Date, or Currency)
Concatenate Both expressions are String
Add One expression is a numeric data type and the other is any Variant except Null
Concatenate One expression is a String and the other is any Variant except Null
Return the remaining expression unchanged as result One expression is an Empty Variant
A Type mismatch error occurs One expression is a numeric data type and the other is a String
result is Null Either expression is Null

If both expressions are Variant expressions, the following rules apply:

Operation performed If
Add Both Variant expressions are numeric
Concatenate Both Variant expressions are strings
Add One Variant expression is numeric and the other is a string

For simple arithmetic addition involving only expressions of numeric data types, 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, Integer, Long, Single, Double, and Currency. The following are exceptions to this order:

Note   The order of precision used by addition and subtraction is not the same as the order of precision used by multiplication.

If one or both expressions are Null expressions, result is Null. If both expressions are Empty, result is an Integer. However, if only one expression is Empty, the other expression is returned unchanged as result.