34,333
edits
Changes
no edit summary
In the real world, humans communicate usign using words and sentences. Given that most computer applications need to interact with humans it is not surprising that the average Visual Basic programmer spends a lot of time dealing with words and sentences in the form of String ''Strings'' when developing applications.
In this chapter we will explore the subject of manipulating strings in Visual Basic.
== Extracting Text from the Beginning of String ==
A portion from the beginning of a string can be extracted using the ''Microsoft.VisualBasic.Left()'' function. This function takes two parameters, the string from which the text is to be extracted and the number of characters to extract. For example, the following code extracts the word "This" from the string:
<pre>
== Extracting Text from Anywhere in a String ==
So far we have looked at extracting text from the beginning and end of a string. Visual Basic also provides a function for extracting any any number of characters from any position in a string. This is achieved using the Visual Basic ''Mid()'' function.
The ''Mid()'' function accepts two mandatory and one optional parameter as follows:
== Replacing Text in String ==
Visual Basic provide provides the ''Replace()'' function for the purposes of replacing some text in a string with some other text. The syntax for the ''Replace()'' function is as follows:
'''Replace(''' ''string'', ''searchtext'', ''replacetext'' ''')'''