关键字参考


Enum

枚举常量.

[作用范围] Enum [Step <步进值>] <常量列表>

参数

作用范围 [可选参数] 范围有三种类型 Local, Global, Dim 或者没有. 如果没有, 将使用 Dim .
步进值 [可选参数] 默认为每次添加 1. 其它可能的步进方法: *n, +n, -n 这里 n 是一个整数.
常量列表 需要枚举的常量列表.

注意/说明

By default, the first constant will be 0 and the rest will be incremented by 1 from there.
When using the multiply operator to step, the first constant will be assigned 1 and the rest will be multiplied based on the previous constant value.
Constants can be explicitly assigned by any valid statement.

相关

示例/演示


Global Enum $E1VAR1, $E1VAR2, $E1VAR3
MsgBox(4096, "", "期望值 0: " & $E1VAR1)
MsgBox(4096, "", "期望值 1: " & $E1VAR2)
MsgBox(4096, "", "期望值 2: " & $E1VAR3)

Global Enum $E2VAR1 = 10, $E2VAR2, $E2VAR3 = 15
MsgBox(4096, "", "期望值 10: " & $E2VAR1)
MsgBox(4096, "", "期望值 11: " & $E2VAR2)
MsgBox(4096, "", "期望值 15: " & $E2VAR3)

Global Enum Step *2 $E3VAR1, $E3VAR2, $E3VAR3
MsgBox(4096, "", "期望值 1: " & $E3VAR1)
MsgBox(4096, "", "期望值 2: " & $E3VAR2)
MsgBox(4096, "", "期望值 4: " & $E3VAR3)