Syntax 

Option Base [0|1]


-or-


Option Compare [Binary | Text]


-or-


Option Explicit


-or-


Option Strict [On | Off | Enum]


-or-


Option UsesAmbiguousError [On | Off]


Group 

Declaration 


Description 

Option Base: Set the default base index for array declarations. Affects Dim, Static, Private, Public and ReDim. Does not affect Array, ParamArray or arrays declare in a Type. Option Base 0 is the default.

Option Compare: Set the default comparison mode for <, <=, =, >, >=, <>, Like and StrComp.


  • Option Compare Binary - compare string text using binary data (default)
  • Option Compare Text - compare string text using the collation rules


Option Explicit: Require all variables to be declared prior to use. Variables are declared using Dim, Private, Public, Static or as a parameter of Sub, Function or Property blocks.

Option Strict: Set the default strict mode for type conversion.


  • Option Strict On - not supported
  • Option Strict Off - allow most implicit type conversions (default)
  • Option Strict Enum - disallow implicit conversion to Enum types


Option UsesAmbiguousError On: When an unqualified symbol not defined in the current macro and it is defined in more than one '#Uses, an "Ambiguous name" error occurs. (This is the default.) Turning off this error allows the "first" matching symbol in a '#Uses to be matched. The '#Uses providing the "first" matching symbol is implementation dependent and not predictable.


Example

Option Base 1

Option Explicit

 

Sub Main

    Dim A

    Dim C(2) ' same as Dim C(1 To 2)

    Dim D(0 To 2)

    A = 1

    B = 2 ' B has not been declared

End Sub