This documentation is archived and is not being maintained.

Concatenation Operators

Concatenation operators join multiple strings into a single string. There are two concatenation operators, + and &; both carry out the basic concatenation operation, as shown below:

Dim x As String
x = "Con" & "caten" & "ation"   ' x equals "Concatenation".
x = "Con" + "caten" + "ation"   ' x equals "Concatenation".

These operators can also concatenate String variables, as in the following example:

Dim x As String = "abc"
Dim y As String = "def"
Dim z As String
z = x & y   ' z equals "abcdef".
z = x + y   ' z equals "abcdef".

If Option Strict is On, the + operator explicitly requires strings for concatenation operations. It also carries out arithmetic operations with numeric operands when Option Strict is On. If Option Strict is Off, however, the + operator supports a wide variety of implicit conversions for concatenation operations. For further information on these conversions, see + Operator.

The & operator is defined only for String operands, and it always widens its operands to String, regardless of the setting of Option Strict. The & operator is recommended for string concatenation because it is defined exclusively for strings and reduces your chances of generating an unintended conversion.

See Also

& Operator | + Operator | Option Strict Statement | String Manipulation