VBA - Strings
Strings are a sequence of characters, which can consist of either alphabets, numbers, special characters, or all of them. A variable is said to be a string if it is enclosed within double quotes " ".
variablename = "string"
str1 = "string" ' Only Alphabets str2 = "132.45" ' Only Numbers str3 = "!@#$;*" ' Only Special Characters Str4 = "Asc23@#" ' Has all the above
There are predefined VBA String functions, which help the developers to work with the strings very effectively. Following are String methods that are supported in VBA. Please click on each one of the methods to know in detail.
|S.No.||Function Name & Description|
Returns the first occurrence of the specified substring. Search happens from the left to the right.
Returns the first occurrence of the specified substring. Search happens from the right to the left.
Returns the lower case of the specified string.
Returns the upper case of the specified string.
Returns a specific number of characters from the left side of the string.
Returns a specific number of characters from the right side of the string.
Returns a specific number of characters from a string based on the specified parameters.
Returns a string after removing the spaces on the left side of the specified string.
Returns a string after removing the spaces on the right side of the specified string.
Returns a string value after removing both the leading and the trailing blank spaces.
Returns the length of the given string.
Returns a string after replacing a string with another string.
Fills a string with the specified number of spaces.
Returns an integer value after comparing the two specified strings.
Returns a string with a specified character for specified number of times.
Returns a string after reversing the sequence of the characters of the given string.