String Manipulation Functions in Visual Basic 2010

String Manipulation Functions in Visual Basic 2010

String are variables non-numeric in nature. String manipulation means writing code to process strings. Some examples of strings can be names, addresses, sentences, genders and so on. String can contain alphabets, numbers and other characters.

Visual Basic 2010 supports various string manipulation functions. Some of these functions are built-in and some are user defined. Here we will be discussing some of the most popular string manipulation functions.

String Manipulation Using (+) and (&) sign:

Both + and & sign are used to concatenate string in Visual Basic 2010. You can use it when you want to combine strings and make a larger string. Example program can be;

Output:

Output 1 String

You can also replace the (+) sign with (&) sign and still get the same result.

Output:

Output 2 String

String Manipulation Built-in Functions in Visual Basic 2010:

Function is similar to sub or procedure. However; a function can return a value to the calling code. The functions described below are all built-in functions which are used to manipulate the strings in Visual Basic 2010.

  1. Len Function
    This function is used to find the length of a string. The syntax can be like;

    Where (character-number) is the number of characters that have to be extracted from the left of the text.

    Output:
    Output 3
    See Also:   Basic Calculator in Visual Basic 2010
  2. Right Function
    This function is used to extract the pre-specified right portion of the text you have entered.

    In the syntax of this function, you can specify how many characters of the text you have entered should be extracted.  Like;

    Where (character-number) is the number of characters that have to be extracted from the right of the text.

    Output:
    Output 5

  3. Left Function
    The same as the Right Function; Left Function is used to extract the left pre-specified portion of the text you have entered.

    Output:
    Output 6

  4. Mid Function
    This function is used to extract a sub string from the original string. The following is the syntax.

    Where (position) is the position of the character from where the extraction should start and the (character-number) is the number of characters that have to be extracted from the text.

    Output:
    Output 7

There are various other string manipulation built-in functions in Visual Basic 2010. We will further be talking about the rest of them in the upcoming tutorials. Keep visiting us to stay updated on programming languages Visual Basic 2010, PHP, HTML5 and etc.

Previous The Most Useful Windows Shortcut Keys
Next Looping Structures in Visual Basic 2010

About author

Bahonar Javid
Bahonar Javid 43 posts

<p>* Computer Application Student<br /> * Co-Founder of www.codejow.com<br /> * Love to code and Learn new languages<br /> * Enjoy playing football</p>

View all posts by this author →

You might also like