Is it possible to loop through Enum Type values to fill combo box?

Working with VB6 and I have this:

Private Enum LoanPurpose
          Undefined = 0
          Purchase  = 1
          Refinance = 2
End Enum

I have a combo box called cmbLoanPurpose that I would like to loop through and get its list values from the LoanPurpose enum type with the itemdata property set to the enum value.

Something like this is what I would like to do:

For each value in LoanPurpose
     cmbLoanPurpose.AddItem EnumName
     cmbLoanPurpose.ItemData = EnumValue
Next value

I am trying to avoid having to add each one individually (or having 3 additem lines) because this is just one example but I have hundreds more that have up to 50 values

Thanks!

careyadkinsAsked:
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.

codeconquerorCommented:
No, not in VB6, I believe you might be able to in .NET.
careyadkinsAuthor Commented:
So there are no workaround or tricks to accomplish this?  Its purely a "can't do"?
codeconquerorCommented:
You could try something like this:

<CODE SNIPPET>
Private Enum Stuff
    Add = 0
    Delete = 1
    Subtract = 2
    Unknown = 3
End Enum

Private Const MAX_STUFF = 3

Public colItems As New Collection
Public vPossibleStuff(MAX_STUFF) As String

Private Sub Form_Load()
Dim iStuff As Integer
vPossibleStuff(0) = "Add"
vPossibleStuff(1) = "Delete"
vPossibleStuff(2) = "Subtract"
vPossibleStuff(3) = "Unknown"
For iStuff = LBound(vPossibleStuff) To UBound(vPossibleStuff)
    colItems.Add vPossibleStuff(iStuff)
Next
'**** Now that we have the objects defined and a collection created (which we can put into a module
'**** and declare as public so the entire project has access to it
'
'**** Then use it like this:

For iStuff = 1 To colItems.Count
    Combo1.AddItem colItems.Item(iStuff)
Next
End Sub
</CODE SNIPPET>

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
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
Visual Basic Classic

From novice to tech pro — start learning today.