String Functions

Here are some commonly used VB string functions:

Function Description
Left(str, numchar) Extracts the specified number of characters from the left side of the string str.
Right(str, numchar) Extracts the specified number of characters from the right side of the string str.
Mid(str, startchar, [numchar]) Extracts a string of length numchar from the middle of str, starting at startchar. If numchar is omitted, the entire right-hand portion of the string, beginning at startchar, is extracted.
Len(str) Returns the length of str.
UCase(str) Converts the string to all uppercase characters.
LCase(str) Converts the string to all lowercase characters.
LTrim(str) Returns a copy of the string without leading spaces
RTrim(str) Returns a copy of the string without trailing spaces
Trim(str) Returns a copy of the string without leading or trailing spaces
StrReverse(str) Returns a copy of the string in reverse order
Replace(expression, find, replace, [start], [count], [compare]) Replaces each instance of “find” with “replace” in “expression”.
InStr([start], string1, string2, [compare]) Returns an integer representing the position of string2 inside string1Start is an optional starting location (if omitted, search starts at position 1).  If string2 is not found in string1, the function returns zero.