CitectVBA supports the use of file scope Option
statements which determine the default behaviour of some CitectVBA functions. For instance, the Option Explicit
statement causes the CitectVBA compiler to produce compile errors whenever it encounters the use of previously undeclared variables. The
Option Compare
statement sets the default comparison method for string comparisons. The Option Base
statement sets the default base number for CitectVBA variable arrays to either zero or one.
You must declare all option
statements in CitectVBA at the beginning of your CitectVBA code files.
As in other BASIC programming languages, CitectVBA supports the declaration of variables both implicitly and explicitly. An unfortunate consequence of implicit variable declaration is the possible misspelling of the variable name in subsequent code writing, with unreliable program behaviour and unpredictable consequences.
To minimize implicit declaration, and to foster good, consistent programming standards, use the option explicit
statement at the beginning of all your CitectVBA files:
Option Explicit
This causes the CitectVBA compiler to produce a compile error whenever it encounters an undeclared variable. This can be useful in locating and identifying variable name typing errors in your CitectVBA code at compile time, thus trapping and minimizing the likelihood of runtime errors caused by such mistakes.
The Option Compare
statement determines how strings are compared within a CitectVBA file, and like other Option
statements in CitectVBA, should be declared at the beginning of your CitectVBA code files.
When strings are compared using CitectVBA functions such as StrComp()
or InStr()
, CitectVBA determines whether they contain equivalent characters and how they differ if they do not match.
Note: When comparing strings, CitectVBA compares the ANSI values of each character in the strings. For example, the character capital 'A' has the ANSI value of 65, and the character lowercase 'a' has the ANSI value of 97. For a listing of ANSI character values, see ASCII/ANSI Character Code Listings.
You can use the Option Compare
statement to specify the default case-sensitivity behavior for CitectVBA functions when making string comparisons.
The Option Compare
statement in CitectVBA has two settings:
The Option Base
statement determines the default base number for the indexing of variable arrays created within a CitectVBA file, and like other Option
statements in CitectVBA, should be declared at the beginning of your CitectVBA code files.
There are two settings for the Option Base
statement in CitectVBA:
For an example of using the Option Base statement, see Fixed Size Arrays
See Also
Published June 2018