Visual Basic Language Reference  

& Operator

Generates a string concatenation of two expressions.

result = expression1 & expression2

Parts

result
Required. Any String or Object variable.
expression1
Required. Any expression.
expression2
Required. Any expression.

Remarks

If the data type of expression1 or expression2 is not String, it is converted to String. The data type of result is String. If one or both expressions are stated as Nothing or have a value of DBNull.value, they are treated as a string with a value of "".

Example

This example uses the & operator to force string concatenation. The result is a string value representing the concatenation of the two string operands.

Dim myStr As String
myStr = "Hello" & " World"   ' Returns "Hello World".

The following example uses the & operator to force string concatentaion on the result of a database lookup. The result is the string value from the database or an empty string in the case of a null value.

Dim rs As Recordset = Cmd.Execute("Select * from ?")
Dim myStr As String
myStr=rs("au_id") & ""

See Also

&= Operator | Concatenation Operators | Operator Precedence in Visual Basic | Operators Listed by Functionality | Concatenation Operators