Comparing Strings
You can compare strings to determine whether they contain equivalent characters and how they differ if they do not match. When you compare two strings, you're actually comparing the ANSI value of each character to the value of the corresponding character in the other string. You can specify whether you want to make comparisons case-sensitive or whether you want to ignore the case and simply compare the strings' characters.
In This Section
- Specifying the String-Comparison Setting for a Module
Understand the three settings for the Option Compare statement. - Comparing Strings by Using Comparison Operators
Use the same comparison operators that you would use with numeric expressions — greater than (>), less than (<), equal to (=), as well as Like, to compare strings. - Overriding the Default String-Comparison Setting
Learn how to perform a string comparison within a procedure and override the string-comparison setting for the module.
Related Sections
- Working with Strings
Understand how to get information from strings. - Calculating String Length
Determine the length of a string using the Len function to parse its contents. - Searching a String
Search strings to find out whether they contains a particular character or group of characters by using the InStr or InStrRev functions. - Returning Portions of a String
Learn how to parse the string to be able to work with part of a string's contents. - Working with Strings as Arrays
Quickly turn once-lengthy string-manipulation procedures into just a few lines of code. - Finding and Replacing Text Within a String
Find and replace all occurrences of a substring within a string using the Replace function. - Converting Text in a String from One Case to Another
Use the Microsoft® Visual Basic® for Applications (VBA) StrConv function to convert text in a string from one case to another. - Working with String Variables
Understand how to dimension a variable, assign a value to it, and output that variable as part of a string.