Sets the string comparison method to sort equivalent text characters as equal.


The Option Compare statement must appear in a source file before any other statements. It affects string comparison for all code generated by that source file.

When to Use Text

If your strings contain all text characters, you often want to compare them, taking into account alphabetic equivalences such as case insensitivity and closely related letters. For example, you might want to consider A and a to be equal, and Ä and ä to come before B and b. To specify a text comparison, set Option Compare to Text.

The Text keyword can be used in this context:

Option Compare Statement

See Also



Visual Basic Language Keywords