How to: Iterate Through An Enumeration - Visual Basic (original) (raw)

Enumerations provide a convenient way to work with sets of related constants, and to associate constant values with names. To iterate through an enumeration, you can move it into an array using the GetValues method. You could also iterate through an enumeration using a For...Each statement, using the GetNames or GetValues method to extract the string or numeric value.

To iterate through an enumeration

Dim items As Array  
items = System.Enum.GetValues(GetType(FirstDayOfWeek))  
Dim item As String  
For Each item In items  
    MsgBox(item)  
Next  

See also