String Manipulation Functions

 

String  manipulation functions are fun to play with, especially something to do with word games. Some of the functions are Left, Right, Mid and Space, I will explain each one of them.

1. Left

The format of Left is

  Left (string, n)

where string might be a word, a phrase or  a paragraph, where it will select the leftmost n characters of the string.

For example, if   w="abcde", then Left(w,3) will return "abc"

 

2. Right

The format of Right is

Right(sting,n).

Right is the opposite of Left, where it will return the right most n characters.

For example, Right("abcdef",4) with return "bcdef"

3. Mid

The Mid format is

Mid(String, position,n)

where position is the starting position of the string from which it will extract a substring from the original string and n is the number of characters to be extracted.

For example, Mid("Visual Basic",3,6)=ual Bas

4. Space

The format of Space is

Space(n)

where n is the number of space created.

 

So, to print out some thing like

we use the codes like below:

Private Sub Command1_Click()
W = "abcdefghijklmnopqrstvwxyz"
For n = 1 To 26 Step 2
Print Space(26 - n) & (Left(W, n))
Next


End Sub
 

 

[Back to VBToday]