We help IT Professionals succeed at work.
Get Started

Loop through an Enum Statement

3,531 Views
Last Modified: 2013-11-26
The solution includes use of an Enum Statement. I looked for a way to loop through the members and found this code on Microsoft's website:

Public Enum flavorEnum
  salty
  sweet
  sour
  bitter
End Enum

Private Sub TestMethod()
  MsgBox ("The strings in the flavorEnum are:")
  Dim i As String
  For Each i In [Enum].GetNames(GetType(flavorEnum))
      MsgBox (i)
  Next
End Sub

That looks easy enough, but my computer complains that GetType isn't declared as a variable. On the off-chance that it makes sense I looked for mscorlib.dll but didn't find it among my system files. I found that mscorlib.dll belongs to .NET. So, perhaps that is a dead end.
Now, whether or not mscorlib.dll can run on my computer (Windows 2000 SP4) and whether or not it contains the GetType function isn't really my primary concern. What would be very useful to me is a way to iterate through the members of an Enum Statement - perhaps just in the way the above code promises to do.
Any advice any one? :-)
awink
Comment
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE