Option Explicit statement

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.

See Also

Option Explicit statement

Variable declaration

Option Statements

Published June 2018