Isi

# Pernyataan Enumerasi [VBA]

Define enumerations or non UNO constant groups. An enumeration is a value list that facilitates programming and eases code logic review.

This constant, function or object is enabled with the statement Option VBASupport 1 placed before the executable program code in a module.

### Sintaksis:

           Enum list_name
               ' Object Statement block
           End Enum ' list_name

## Parameter:

Dalam enumerasi yang diberikan, cocokkan nilai-nilai yang secara logis berhubungan satu sama lain.

### Contoh:

           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.

## Penggunaan:

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.

Topik Terkait

Const pernyataan, konstan

Option VBASupport statement

With statement