Siebel VB Language Reference > VB Language Reference >
Option Explicit Statement
This standard VB statement specifies that every variable in a module must be explicitly declared. Syntax
Option Explicit
Returns
Not applicable Usage
By default, Basic declares any variables that do not appear in a Dim, Global, ReDim, or Static statement. Option Explicit causes such variables to produce a "Variable Not Declared" error. Using the Option Explicit statement makes debugging code easier, because it forces you to declare variables before use. Good programming practice is to declare variables at the beginning of the unit within which they have scope (that is, at the beginning of the project, module, or procedure). Declaring variables in this manner simplifies finding their definitions when reading through code. The Option Explicit statement must be placed in the (general) (declarations) section in the Siebel VB Editor, as shown in Option Base Statement. Example
This example specifies that variables must be explicitly declared, thus preventing any mistyped variable names. Option Explicit Sub Button_Click Dim counter As Integer Dim fixedstring As String * 25 Dim varstring As String '...(code here)... End Sub
Related Topics
Const Statement Deftype Statement Dim Statement Function...End Function Statement Global Statement ReDim Statement Static Statement Sub...End Sub Statement
|