Every Visual Basic developer quickly learns how to manipulate
strings, but it’s often easy to overlook some of the more powerful
techniques available, especially with all the new features in Visual
Basic 2005. A good example is the powerful
StringBuilder object, which provides an
order-of-magnitude improvement for concatenating strings. Visual Basic 6
developers, in particular, will discover lots of exciting new
string-processing features. For example, Visual Basic 2005’s
Substring() method provides similar
functionality not only to the
function, but also to the
Right() string functions. The regular
expression library included with .NET also provides new and powerful
ways to analyze and process string data.
You need to process many pieces of string data with more efficiency than is allowed using standard .NET Framework immutable strings.
provides extremely fast and efficient in-place processing of string
and character data. The following code demonstrates several of its
powerful methods and some of the techniques you can use to speed up
your string processing:
Dim workText As New System.Text.StringBuilder ' ----- Build a basic text block. workText.Append("The important") workText.Append(vbNewLine) workText.Append("thing is not") workText.AppendLine() workText.AppendLine("to stop questioning.") workText. Append("--Albert Einstein") MsgBox(workText.ToString( )) ' ----- ...