Option Compare in VBA is the thing, that will save you ugly stuff like this one:
1 2 3 4 5 6 7 8 9 10 |
Sub Testing() Dim userInput As String userInput = InputBox("What is decimal 4094 in hex?") If UCase(userInput) = UCase("ffe") Then Debug.Print "You have correctly written " + userInput + "!" End If End Sub |
Yup, it is a bit ugly, using UCase to compare all the time, between small letter text and big letter text. So, if you want to ignore the cases in VBA, this is the correct way to do it.
Option Compare Text
This is TRUE, if Option Compare Text is in the module:
1 2 3 4 5 6 |
Option Explicit Option Compare Text Sub TestMe() Debug.Print "VITOSH" = "vitosh" End Sub |
Option Compare Binary
This is FALSE, if Option Compare Binary is in the module:
1 2 3 4 5 6 |
Option Explicit Option Compare Binary Sub TestMe() Debug.Print "a" = "A" End Sub |
Option Compare Database
Do not use this one.
It is used in MS Access and based on the db settings it determines the usage of either Option Compare Text or Option Compare Binary. With other words – same code, different execution, as the DB settings can differ.