Getting It Together with Concatenation Operators

You can concatenate strings using either the plus (+) operator or the ampersand (&) operator. The following statements are equivalent:

strResult = "Welcome to " + "my circus."
strResult = "Welcome to " & "my circus."

Experienced programmers, however, never use the plus (+) operator for joining strings. There are two very good reasons for this:

  • It’s very easy to code an expression such as a + b that you think will concatenate the variables a and b. However, if the variables are numeric, this expression actually adds them. The expression a & b always performs a concatenation.

  • Visual Basic .NET halts with a compilation error if you use the plus (+) operator to concatenate a mixture of String variables ...

Get Faster Smarter Beginning Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.