1 关键字分类
VBA的关键字比较多,最重要的当然是类型和流程控制两类。

2 数据类型分类

3 运算符分类

附:
|
keyword |
remark |
|
accessor |
Property Get |
自定义类的属性的访问控制为读 |
|
accessor |
Property Let |
自定义类的属性的访问控制为写 |
|
accessor |
Property Set |
自定义类的属性的访问控制为写(对象) |
|
array |
Array |
|
|
array |
ReDim |
数组大小重定义 |
|
assignment |
Set |
Set obj = Nothing |
|
declaration |
As |
|
|
declaration |
Declare |
Declare Function ReadFile Lib "kernel32" (…… API declaration |
|
event |
Event |
Public Event SomethingHappened(ByVal something As String) |
|
event |
RaiseEvent |
RaiseEvent SomethingHappened("hello") |
|
flow control |
Case |
Select Case n …… Case 1 ……Case 2 ……Case Else …… End Select |
|
flow control |
Case Else |
Select Case n …… Case 1 ……Case 2 ……Case Else …… End Select |
|
flow control |
Do |
Do …… Loop While ……, Do …… Loop Untill …… |
|
flow control |
Do Until |
Do Until …… Loop |
|
flow control |
Do While |
Do While …… Loop |
|
flow control |
Else |
If …… Else …… End If, Case Else |
|
flow control |
ElseIf |
If …… ElseIf …… End If |
|
flow control |
Exit |
Exit End |
|
flow control |
For |
For i = 1 to 10 …… Next i |
|
flow control |
For Each |
For Each c In rng.Cells …… Next |
|
flow control |
Goto |
On Error Goto label |
|
flow control |
If |
If i > 5 Then …… End If, If …… Else …… End If |
|
flow control |
If Not |
If Not …… Then …… End If |
|
flow control |
In |
For Each c In rng.Cells |
|
flow control |
Loop |
|
|
flow control |
Loop While |
Do …… Loop While …… |
|
flow control |
Next |
For i = 1 to 10 …… Next i |
|
flow control |
Resume |
Resume label |
|
flow control |
Select |
Select Case n …… Case 1 ……Case 2 ……Case Else …… End Select |
|
flow control |
Step |
循环步长定义,For i = 1 To 10 Step 2 …… Next i |
|
flow control |
Then |
If i > 5 Then …… End If |
|
flow control |
To |
For i = 1 To 10 Step 2 …… Next i |
|
flow control |
Wend |
While …… Wend |
|
flow control |
While |
While …… Wend |
|
interface |
Implements |
接口实现 |
|
logical |
And |
|
|
logical |
Eqv |
|
|
logical |
Imp |
not xor, implication |
|
Logical |
Not |
|
|
logical |
Or |
|
|
logical |
Xor |
|
|
module |
End |
|
|
module |
Enum |
自定义枚举 |
|
module |
Function |
|
|
module |
Type |
Private Type Tmodel …… End Type |
|
module |
Lib |
Declare Function ReadFile Lib "kernel32" ( |
|
module |
Me |
Me.Hide 控件自引用 |
|
module |
call |
Call DoSomething : DoSomethingElse |
|
module |
Sub |
|
|
operator |
Mod |
Modulo |
|
others |
Alias |
Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" ( |
|
flow control |
Error |
On Error |
|
others |
New |
Set obj = new class, With New UserForm1 |
|
flow control |
On |
On Error |
|
others |
Option |
Option Explicit |
|
others |
Rem |
备注 |
|
others |
With |
对象引用层次缩写 |
|
parameter |
Byref |
|
|
parameter |
Byval |
|
|
parameter |
Optional |
可选函数参数 |
|
relational |
Is |
If obj Is Nothing |
|
scope |
Dim |
procedural Scope |
|
scope |
Friend |
friend class scope, within the project |
|
scope |
Private |
module scope |
|
scope |
Public |
global scope |
|
scope |
Static |
storage class |
|
specifier |
Const |
delimiter |
|
type |
Withevents |
Private WithEvents Foo As Workbook |
|
type |
Boolean |
2 |
|
type |
Byte |
无符号数类型,取值范围0-255 |
|
type |
Currency |
8 |
|
type |
Date |
8 |
|
type |
Decimal |
14 |
|
type |
Double |
8 |
|
type |
Integer |
|
|
type |
Long |
4 |
|
type |
Object |
4 |
|
type |
Single |
4 |
|
type |
String |
|
|
type |
Variant |
|
|
value |
False |
|
|
value |
Nothing |
Set obj = Nothing |
|
value |
Null |
|
|
value |
True |
ref:
VBA处理的数据:变量、常量、数组、集合、字典与对象属性
VBA|自定义过程、函数、类型、枚举、类(属性及操作和类过程)
-End-