Link to home
Start Free TrialLog in
Avatar of awink
awinkFlag for Singapore

asked on

Loop through an Enum Statement

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
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)
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? :-)
Avatar of DerSpinner
Flag of Malta image

Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of awink


I am just learning to use Enum. So, iterating through its members seems to be on everybody's mind at that stage. Until such time that I upgrade to .NET I will just do without.
Thank you.