- VBA - Userforms
- VBA - Programming Charts
- VBA - Text Files
- VBA - Excel Objects
- VBA - Error Handling
- VBA - Events
- VBA - Sub Procedure
- VBA - Functions
- VBA - Arrays
- VBA - Date and Time
- VBA - Strings
- VBA - Loops
- VBA - Decisions
- VBA - Operators
- VBA - Constants
- VBA - Variables
- VBA - Input Box
- VBA - Message Box
- VBA - Macro Comments
- VBA - Excel Terms
- VBA - Excel Macros
- VBA - Overview
- VBA - Home
VBA Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
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 " ".
Syntax
variablename = "string"
Examples
str1 = "string" Only Alphabets str2 = "132.45" Only Numbers str3 = "!@#$;*" Only Special Characters Str4 = "Asc23@#" Has all the above
String Functions
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 cpck on each one of the methods to know in detail.
Sr.No. | Function Name & Description |
---|---|
1 |
Returns the first occurrence of the specified substring. Search happens from the left to the right. |
2 |
Returns the first occurrence of the specified substring. Search happens from the right to the left. |
3 |
Returns the lower case of the specified string. |
4 |
Returns the upper case of the specified string. |
5 | Returns a specific number of characters from the left side of the string. |
6 | Returns a specific number of characters from the right side of the string. |
7 |
Returns a specific number of characters from a string based on the specified parameters. |
8 |
Returns a string after removing the spaces on the left side of the specified string. |
9 |
Returns a string after removing the spaces on the right side of the specified string. |
10 |
Returns a string value after removing both the leading and the traipng blank spaces. |
11 |
Returns the length of the given string. |
12 |
Returns a string after replacing a string with another string. |
13 |
Fills a string with the specified number of spaces. |
14 |
Returns an integer value after comparing the two specified strings. |
15 |
Returns a string with a specified character for specified number of times. |
16 |
Returns a string after reversing the sequence of the characters of the given string. |