Option Explicit Statement

指定必須使用 Dim 陳述式明確宣告程式碼中的每個變數。

Syntax:

Option Explicit

Parameters:

warning

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 這將導致執行階段錯誤
        Rem
    Next i%
End Sub

Please support us!