\<bookmark_value\>Option Explicit statement\</bookmark_value\>

Option Explicit Statement

Specifies that every variable in the program code must be explicitly declared with the Dim statement.

Syntax:


Option Explicit

Parameters:

Warning Icon

This statement must be added before the executable program code in a module.


Example:


Option Explicit
Sub ExampleExplicit
Dim sVar As String
    sVar = "Las Vegas"
    For i% = 1 to 10 REM This results in a run-time error
        Rem
    Next i%
End Sub

If this page has been helpful, you can support us!