VBA – Option Compare (Text || Binary || Database)

Option Compare  in VBA is the thing, that will save you ugly stuff like this one:

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:

Option Compare Binary

This is FALSE, if Option Compare Binary is in the module:

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.

Once you start ignoring captions in string comparison you never go back!

Tagged with: , , , , ,