VB and VBA Users Source Code: Looping over the values held in an enumerated data type (enum)
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Looping over the values held in an enumerated data type (enum)
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, August 15, 2001
Hits:
684
Category:
Visual Basic General
Article:
The Enumerated data type is an excellent way to store related constants. However, it lacks any functionality to integorate the values held in the type. The following is a work around which shows how to loop over the numerical values it holds: 'Note, the values held between the "[_]" are hidden enums Public Enum eEnumDemo [_LBound] 'Will be assigned a value of zero eEnumDemo1 eEnumDemo2 eEnumDemo3 eEnumDemo4 [_UBound] 'Will be assigned the highest value + 1 End Enum Sub Test() Dim lCounter As Long For lCounter = eEnumDemo.[_LBound] + 1 To eEnumDemo.[_UBound] - 1 Debug.Print lCounter Next End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder