& Operator
Visual Studio .NET 2003
Generates a string concatenation of two expressions.
result = expression1 & expression2
Parts
- result
- Required. Any String or Object variable.
- expression1
- Required. Any expression with a data type that widens to String.
- expression2
- Required. Any expression with a data type that widens to String.
Remarks
If the data type of expression1 or expression2 is not String but widens to String, it is converted to String. If one of the data types does not widen to String, the compiler generates an error.
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".
See Also
&= Operator | Concatenation Operators | Operator Precedence in Visual Basic | Operators Listed by Functionality | Concatenation Operators