VBA/Excel/Access/Word/Data Type/Enum
Control the long integer value assigned to each item in the list, simply set the constant equal to a value
<source lang="vb">
"Working with Enumerated Types Public Enum PersonTypeList
Client = 10 PersonalContact = 5 Vendor = 2 Other = 999
End Enum Sub EnumM()
Dim pt As PersonTypeList pt = Client Debug.Print pt
End Sub
</source>
Creating an Enum
<source lang="vb"> Public Enum SystemMetrics SM_MOUSEPRESENT = 19 SM_SWAPBUTTON = 23 SM_MOUSEWHEELPRESENT = 75 End Enum Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As SystemMetrics) As Long
Type RECT
Left As Long Top As Long Right As Long Bottom As Long
End Type Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long Sub Foo()
Dim rectClipArea As RECT Dim lngRetVal As Long With rectClipArea .Top = 200 .Left = 100 .Bottom = 420 .Right = 280 End With lngRetVal = ClipCursor(rectClipArea)
End Sub
</source>
Working with Enumerated Types
<source lang="vb">
" Public Enum PersonTypeList
Client PersonalContact Vendor Other
End Enum Sub EnumM()
Dim pt As PersonTypeList pt = Client Debug.Print pt
End Sub
</source>