Set String Comparison Method
The Set String Comparison method specifies the default method for string comparisons to case-sensitive or not case-sensitive. It does not return a value. You must include this method in the general declarations section. Note the following:
A binary comparison is case-sensitive. It compares strings according to the ANSI character set. A lowercase letter is different from an uppercase letter.
A text comparison is not case-sensitive. It compares strings according to the relative order of characters. The country code setting for your computer determines this order.
Format
Option Compare {Binary | Text}
This statement does not include arguments.
Example
The following example compares the following strings:
Jane Smith
jane smith
If Set String Comparison is Text, then these strings are the same. If Set String Comparison is Binary, then these strings are not the same. Binary is the default value. To examine this difference, you can run the example, comment out the Set String Comparison method, and then run it again:
Option Compare Text
Sub Button_Click
Dim strg1 as String
Dim strg2 as String
Dim retvalue as Integer
strg1 = "JANE SMITH"
strg2 = "jane smith"
i:
retvalue = StrComp(strg1,strg2)
If retvalue = 0 then
‘The strings are identical
Else
‘The strings are not identical
Exit Sub
End If
End Sub