Used to sum two numbers.
result = expression1 + expression2 |
The + operator syntax has these parts:
Part | Description |
result | Required; any numeric variable. |
expression1 | Required; any expression. |
expression2 | Required; any expression. |
If at least one expression is not a Variant, the following rules apply:
If | Then result is |
Both expressions are numeric data types (Byte, Boolean, Integer, Long, Single, Double, Date) | Add. |
Both expressions are String | Concatenate. |
One expression is a numeric data type and the other is any Variant except Null | Add. |
One expression is a String and the other is any Variant except Null | Concatenate. |
If | Then |
Both Variant expressions are numeric | Add. |
Both Variant expressions are strings | Concatenate. |
One Variant expression is numeric and the other is a string | Add. |
If | Then result is |
The data type of result is a Long, Single, or Date variant that overflows its legal range, | converted to a Double variant. |
The data type of result is a Byte variant that overflows its legal range, | converted to an Integer variant. |
The data type of result is an Integer variant that overflows its legal range, | converted to a Long variant. |
A Date is added to any data type, | a Date. |
Dim MyNumber, Var1, Var2 MyNumber = 2 + 2 ' Returns 4. trace MyNumber MyNumber = 4257.04 + 98112 ' Returns 102369.04. trace MyNumber Var1 = "34": Var2 = 6 ' Initialize mixed variables. MyNumber = Var1 + Var2 ' Returns 40. trace MyNumber Var1 = "34": Var2 = "6" ' Initialize variables with strings. MyNumber = Var1 + Var2 ' Returns "346" (string concatenation). trace MyNumber |
See Also |
Operators |