LOTUSSCRIPT LANGUAGE


Addition operator
Finds the sum of two numbers.

Syntax

numExpr1 + numExpr2

Elements

numExpr1, numExpr2


Return value

When adding expressions of numeric data types, the result is a value whose data type in most cases is the same as that of the operand whose data type is latest in this ordering: Integer, Long, Single, Double, Currency. For example, if one operand is a Double and the other is an Integer, then the data type of the result is Double.

The exceptions are:


Usage

LotusScript interprets the + operator as either addition or string concatenation, depending on the data types of expr1 and expr2. The following table lists these interpretations. The numeric data types are Integer, Long, Single, Double, Currency, and (in a Variant variable only) Date/Time.
One expressionOther expressionOperation
NumericNumericAddition
NumericString (Type mismatch error occurs)
NumericVariant (other than NULL)Addition
String Variant (other than NULL)String concatenation
String String String concatenation
Any typeVariant that contains EMPTYReturns first expression
Any typeNULLReturns NULL
Variant of numeric data typeVariant of numeric data typeAddition
Variant of numeric data typeVariant of String data typeAddition, if string can be converted to a numeric data type; otherwise a type mismatch error occurs
Variant of String data typeVariant of String data typeString concatenation
To avoid confusion, use the & operator, not the + operator, for string concatenation.

Language cross-reference

@Sum function in formula language

Example

Dim a As Variant
Dim b As Integer
a = "8"
b% = 7

' Use operator for addition.
Print 8 + 7                           ' Prints 15
Print a + 7                           ' Prints 15
Print 8 + b%                          ' Prints 15
Print a + b%                          ' Prints 15

' Use operator for string concatenation.
Print "Hello " + "there"              ' Prints "Hello there"
Print a + "7"                         ' Prints "87"

See Also