Sets the string comparison method to a strict binary sort order.


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 Binary

You might need to compare string elements based on their true binary value, particularly if the strings can contain characters that are not to be interpreted as text. In such a case you do not want to bias comparisons with alphabetic equivalences such as case insensitivity. To specify a pure binary comparison, set Option Compare to Binary.

The Binary keyword can be used in this context:

Option Compare Statement

See Also



Visual Basic Language Keywords