How to: Determine the String Associated with an Enumeration Value - Visual Basic (original) (raw)

The GetValues and GetNames methods allow you to determine the strings and values associated with enumeration members.

To determine the string associated with an enumeration

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  

See also