String concatenation operators

Concatenate two expressions as strings.

Ampersand (&) operator

Syntax

expr1 & expr2

Elements

expr1, expr2

Any String expressions, or any of the following:

  • Numeric expression: LotusScript® converts it to its text representation. In the case of Boolean data types, 0 becomes "False," and any other number becomes "True."
  • NULL: LotusScript® treats it as an zero-length String value when concatenated with the other expression. If both expressions are NULL, the result is NULL.
  • EMPTY: LotusScript® treats it as a zero-length String value.

Return value

The result is a String or a Variant of type String, if either of the operands is a Variant.

Usage

Use the ampersand (&) operator to ensure a concatenation operation. The plus (+) operator also concatenates two character strings, but LotusScript® determines whether to interpret the plus as a concatenation operator or an addition operator on the basis of the operands in the expression in which it appears.

Examples

Dim x As Variant
x = 56 & " Baker St."
Print x                         ' Prints "56 Baker St."
anInt% = 123
aString$ = "Hello"
anotherString$ = "world"
varV = NULL
Print aString$ & ", " & anInt% & " " & varV & _ 
    anotherString$ & "."
' Output: Hello, 123 world.

Plus (+) operator

Syntax

expr1 + expr2

Elements

expr1, expr2

Any String expressions, or any of the following:

  • Numeric expression: LotusScript® converts it to its text representation (if plus is interpreted as concatenation).
  • NULL: LotusScript® treats it as NULL. If either expression is NULL, the result is NULL.
  • EMPTY: LotusScript® treats it as a zero-length String value.

Return value

The result is a String or a Variant of type String, if either of the operands is a Variant.

Usage

Use the ampersand (&) operator to ensure a concatenation operation. The plus (+) operator concatenates two character strings, but LotusScript® determines whether to interpret the plus as a concatenation operator or an addition operator on the basis of the operands in the expression in which it appears.

For example:

Print 100 & "200"
' Output is 100200, because & is always
' a concatenation operator

while

Print 100 + "200"
' Output is 300, because + was interpreted
' as addition operator

Print "100" + "200"
' Output is 100200, because + was interpreted
' as concatenation operator