Investigate: is the "&" character in VBA string-handling functions the equivalent of "+" in .NET?


I'm seeing more and more instances of "&" in string-handling functions as I continue to review the converted code.  Unfortunately, I'm not familiar enough with VB, VBA or .NET to know whether this is a legal way to concatenate characters together.
If it's not, then the Task is to replace all string-handling-embedded instances of "&" with "+".
Closed Apr 25, 2008 at 4:20 PM by MikeSL


wrote Apr 25, 2008 at 4:06 PM

Apparently the "&" operator is legal in VB, but its equivalent in C# is "+".  I may have gotten confused by the C# I occasionally write.
However, there's plenty of recommendations on using the StringBuilder class where concatenation of any sort is performed - and it's recommended for performance reasons (e.g. "In this situation every application of the '&' (or '+') operator causes the string pointed to by the variable sXml to be destroyed and recreated. As I have already mentioned, string allocation is expensive, becoming increasingly more so as the string grows, and this is the motivation for providing the StringBuilder class in the .NET Framework." and "You should be using the StringBuilder class for all but the most trivial string concatenation (or replace) operations. The extra effort required to use the StringBuilder class is negligible and is far outweighed by the potential performance and scalability benefits to be gained." http://msdn2.microsoft.com/en-us/library/aa302329.aspx#vbnstrcatn_concat).

wrote Apr 25, 2008 at 4:20 PM

wrote Jun 16, 2008 at 6:36 PM

wrote Feb 13, 2013 at 10:01 PM

wrote May 16, 2013 at 3:14 AM