Option explicit

A programmer can force all variable declarations in a program by inserting an Option Explicit command before the procedure definition begins. By inserting this optional command, the VBA program will expect every variable that is used in the program to be declared before it can be used. This is good VBA program practice. An example of Option Explicit follows:

Option Explicit

'Notice how the option explicit command precedes the procedure definition all variables must be declared

Sub thisProg ()

Dim salesChart As Chart

'Specific object Chart declaration must be declared

Dim theTotal As Long

' this variable must be declared since Option explicit has been used

Dim myDaughtersName As String ' this variable must also be declared

0 0

Post a comment