A string is either a character or a group
of character written within double quotes. Like every high level programming language,
Excel-VBA too supports string manipulations. There are several built in
functions which make our job of string manipulation and operation a lot easier.
It would not be possible for me to cover each and every supported function
here. I will touch upon those which are important and frequently used.
Len(String) : This function determines the length of the string
InStr(Start, str1, str2, compare): This function helps to find the occurrence of str1 in str2. If the
match is found, it returns the position of the first match. Start and compare
are optional. Start determines the start position in str2 from where the search
should begin.
Getchar(string, Index): Function return character from the string present at Index
position.
Left( string, length): Fucntion returns specified number
of characters (length) from left-hand side of the string.
Ltrim(string), Ltrim(String), Trim(String): These
functions remove spaces from the string. Ltrim removes spaces present before
the string, Rtrim removes spaces present at the end of the string whereas Trim
removes spaces present at the beginning and at the end of the string.
Mid(string, start, Length): Function returns string of specified length
from the mentioned start position in a string.
Replace(string, search_string, rep_string): This function finds search_string in string
and replaces it with rep_string.
Right(string, length): Function
returns specified number of characters (length) from right-hand side of the
string.
Space(integer): This function returns a string
with specified number of spaces.
Split(String, delimiter): This
function returns one dimensional array of string. This function divides the
specified string at the delimiting points.
Strcomp(String1, strng2): This
function compares two strings and return an integer value.
Strreverse(String); This function reverses the entire
string.
String concatenation is achieved in the following way.
String1 and String2 can be concatenated using ‘+’ sign .
Debug.print “Naveen” +” “+”Tiwari”
Will result in Naveen Tiwari