Avatar of awink
awink
Flag 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
  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
Visual Basic ClassicMicrosoft Excel

Avatar of undefined
Last Comment
awink

8/22/2022 - Mon
DerSpinner

ASKER CERTIFIED SOLUTION
Mike Tomlinson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
awink

ASKER
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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck