Iteration through predefined enumerations

The enumeration vbVarType includes a list of constants such as vbInteger, vbLong, vbSingle, vbDouble, vbArray with values 2, 3, 4, 5, and 8192 respectively.  I want to iterate through the enumeration as have both the names of the constant and the value of the constant.
I found an example that I thought might work that uses the code:

Dim items as array
items = System.Enum.GetValues(GetType(FirstDayOfWeek))

However, this doesn't work for me.  Is there another way to do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:

I can only help you with the syntax, you will have to investigate the Object names on your own.

If you have a form with some controls on it, you can run code like this:

Private Sub Command5_Click()

Dim strHeaders As String
Dim ctl As Control
Dim strAccumulator As String

strHeaders = "ControlName   ControlLeftLocation" & vbCrLf
    For Each ctl In Me.Controls
        strAccumulator = strAccumulator & ctl.Name & "        " & ctl.Left & vbCrLf
    Next ctl
    Debug.Print strHeaders & strAccumulator

End Sub

This code will produce output similar to this:
ControlName   ControlLeftLocation
Command1        4800
Command2        5940
Label3            1440
Label4            2880
Command5        6840

Hope this helps.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
AFAIK, there is no way to get the values out of an Enum at runtime in VB 6 or VBA. The code you have is from a .NET application, which can do this. You can do something like this in the IDE, but it's not a good idea.

Best bet it so examine the Enum and include constants in your code during development (or a list of some sort, depending on your needs).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
drjoeusaAuthor Commented:
It's good to learn that it's not possible to do what you're trying to do.  I'll do it manually until I move to .NEt.  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.