Collabora Office 24.04 Bantuan
Define enumerations or non UNO constant groups. An enumeration is a value list that facilitates programming and eases code logic review.
Enum list_name
' Object Statement block
End Enum ' list_name
Dalam enumerasi yang diberikan, cocokkan nilai-nilai yang secara logis berhubungan satu sama lain.
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
Disebutkan nilai diberikan ketipe datapanjang. Fungsi dasar adalah pengakses publik ke daftar. Daftar nama dan nama nilai harus unik dengan pustaka dan lintas modul.
Tampilan WindowManager mengelompokkan nilai konstan:
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.