VBA: difference between & and +

What's the difference between:

string1 + string2

and

string1 & string2

Are they equivalent? Why do two different characters do the same?

+5
source share
2 answers

The expressions are the same as long as the operands are strings; if not, +may add them instead depending on type conversions. &ensures that you get nothing but the concatenation of strings, and if possible, convert the operands to strings.

There is an MSDN entry on Concatenation Operations in Visual Basic that explains this:

(Visual Basic) String String, Strict. , .

+4

, . + , , & .

+2

All Articles