Chapter 16. Strings

People once thought of computers as manipulating numeric values exclusively. Early computers were first used to calculate missile trajectories, and programming was taught in the math department of major universities.

Today, most programs are concerned more with strings of characters than with numbers. Typically these strings are used for word processing, document manipulation, and creation of web pages.

VB.NET provides built-in support for a fully functional String type. More importantly, VB.NET treats Strings as objects that encapsulate all the manipulation, sorting, and searching methods normally applied to strings of characters.

Complex string manipulation and pattern matching is aided by the use of regular expressions. VB.NET combines the power and complexity of regular expression syntax, originally found only in string manipulation languages such as awk and Perl, with a fully object-oriented design.

In this chapter, you will learn to work with the VB.NET String type and the .NET Framework System.String class that it aliases. You will see how to extract sub-strings, manipulate and concatenate strings, and build new strings with the StringBuilder class. In addition, you will find a short introduction to the RegEx class used to match strings based on regular expressions.

Creating Strings

VB.NET treats strings as if they were built-in types. When you declare a VB.NET String using the String keyword, you are in fact declaring the object to be of the type System.String, ...

Get Learning Visual Basic .NET 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.