Siebel VB Language Reference > Methods Reference for Siebel VB > Variable Manipulation Methods >

Force Explicit Declaration Statement


The Force Explicit Declaration statement forces you to explicitly declare every variable in a module. It does not return a value.

Format

Option Explicit

Usage

Visual Basic declares any variables that does not occur in one of the following statements, by default:

  • Dim
  • Global
  • ReDim
  • Static

If you include the Force Explicit Declaration statement in your code, then Siebel VB creates the following error every time it encounters a variable that is not declared:

Variable Not Declared

Using the Force Explicit Declaration statement makes debugging code easier because it forces you to declare each variable before you use it. It is recommended that you declare variables at the beginning of the project, module, or procedure where these variables possess scope. Declaring variables in this way simplifies locating their definitions when reading through code.

You must include the Force Explicit Declaration statement in the general declarations section. For more information, see Set Array Lower Boundary Method.

Example

The following example specifies that variables must be explicitly declared. This technique prevents 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

Create Subroutine Method
Create Function Method
Declare Symbolic Constant Method
Declare Array Method

Siebel VB Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.