Option Compare
- Last UpdatedJul 18, 2023
- 1 minute read
Determines how strings are compared within a VBA module. The optional Option Compare statement if used, must be placed at the top of the VBA file along with any other Option declarations.
If an Option Compare statement is not included, the default text comparison method is Binary.
Syntax
Option Compare {Binary | Text}
Related Functions
Example
Option Compare Binary
Dim vntResult as Variant
vntResult = StrComp("VBA rules!", "vba Rules!")
' returns 1 (strings unequal)
Example
Option Compare Text
Dim vntResult as Variant
vntResult = StrComp("VBA rules!", "vba Rules!")
' returns 0 (strings equal)