Collabora Office 21.06 帮助
定义枚举或非 UNO 常量组。枚举是值的列表, 可方便编程并简化代码逻辑检查。
Enum list_name
' Object Statement block
End Enum ' list_name
在给定的枚举中, 将逻辑上相互关联的值组合在一起。
Option VBASupport 1
Private Enum _WindowManager
W1ND0WS = 1 ' Windows
OS2PM = 2 ' OS/2 Presentation Manager
MACINTOSH = 3 ' Macintosh
MOTIF = 4 ' Motif Window Manager / Unix-like
OPENLOOK = 5 ' Open Look / Unix-like
End Enum
Public Function WindowManager() As Object
WindowManager = _WindowManager
End Function ' <library>.<module>.WindowManager.XXX
枚举值将呈现为「Long」数据类型。Basic 函数是枚举的公共访问器。枚举名称和值的名称在库中和模块之间必须是唯一的。
显示 WindowManager 分组常量值:
Dim winMgr As Object : winMgr = <library>.<module>.WindowManager
With winMgr
Print .MACINTOSH, .MOTIF, .OPENLOOK, .OS2PM, .W1ND0WS
End With
Enumerations can be extended to other data types using Type statement definitions. Calling Python Scripts from Basic illustrates that mechanism.