VBA关键词用途简要说明-Part 1(Brief Introduction of VBA keywords)
Keword
用途
Usage
IsArray
判断一个变量是否是数组
Returns a Boolean value indicating whether a variable is an array.
Array
返回一个包含数组的variant
Returns a Variant containing an array.
Option Base
更改默认数组下标下限(0或1)
Used at module level to declare the default lower bound for array subscripts.
Dim
声明变量并分配存储空间
Declares variables and allocates storage space.
Private
在模块级别声明私有变量并分配存储空间
Used at module level to declare private variables and allocate storage space.
Public
在模块级别声明公共变量并分配存储空间
Used at module level to declare public variables and allocate storage space.
ReDim
在过程级别为动态数组变量重新分配存储空间
Used at procedure level to reallocate storage space for dynamic array variables.
Static
在过程级别声明静态变量并分配存储空间
Used at procedure level to declare variables and allocate storage space. Variables declared with the Static statement retain their values as long as the code is running.
LBound
返回特定数组维度的下标下限
Returns a Long containing the smallest available subscript for the indicated dimension of an array.
UBound
返回特定数组维度的下标上限
Returns a Long containing the largest available subscript for the indicated dimension of an array.
Erase
重新初始化定长数组并释放动态数组的存储空间
Reinitializes the elements of fixed-size arrays and releases dynamic-array storage space.
#Const
定义条件编译常量
Used to define conditional compiler constants for Visual Basic.
#If...Then...#Else
条件编译所选代码块
Conditionally compiles selected blocks of Visual Basic code.
GoSub...Return
过程中跳转至子程序后从子程序退出
Branches to and returns from a subroutine within a procedure.
GoTo
过程中跳转至指定行后继续执行
Branches unconditionally to a specified line within a procedure.
On Error
错误处理
Enables an error-handling routine and specifies the location of the routine within a procedure; can also be used to disable an error-handling routine.
On...GoSub
跳转至指定后继续执行
Branch to one of several specified lines, depending on the value of an expression.
On...GoTo
跳转至指定行后继续执行
Branch to one of several specified lines, depending on the value of an expression.
DoEvents
停止执行,将控制权转交给系统
Yields execution so that the operating system can process other events.