要求变量声明Option ExplicitResIf used, the Option Explicit statement must appear in a module before any procedures.When Option Explicit appears in a module, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements. If you attempt to use an undeclared variable name, an error occurs at compile time.If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement.Note   Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear.

解决方案 »

  1.   


    Option Explicit 语句      在模块级别中使用,强制显式声明模块中的所有变量。语法Option Explicit说明如果使用,Option Explicit 语句必须写在模块的所有过程之前。如果模块中使用了 Option Explicit,则必须使用 Dim、Private、Public、ReDim 或 Static 语句来显式声明所有的变量。如果使用了未声明的变量名在编译时间会出现错误。如果没有使用 Option Explicit 语句,除非使用 Deftype 语句指定了缺省类型,否则所有未声明的变量都是 Variant 类型的。注意 使用 Option Explicit 可以避免在键入已有变量时出错,在变量的范围不是很清楚的代码中使用该语句可以避免混乱。
    多看看帮助吧,阿呆呆