Option Explicit 语句

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

note

The Option Explicit statement is evaluated at run time.


语法:

Option Explicit

参数:

warning

此语句必须添加到模块中的可执行程序代码之前。


示例:


Option Explicit
Sub ExampleExplicit
Dim sVar As String
    sVar = "Las Vegas"
    For i% = 1 To 10 ' 将导致运行时错误
        Rem
    Next i%
End Sub

请支持我们!