|
|
|
| Title | Easily list the values defined by an Enum in Visual Basic .NET |
| Description | This example shows how to easily list the values defined by an Enum in Visual Basic .NET |
| Keywords | Enum, list values, enumerated values, GetValues, VB.NET |
| Categories | VB.NET, Software Engineering, Tips and Tricks |
|
|
|
The Enum class is the base class for enumerations. It has a GetValues method that returns an array of values defined by an enumerated type. The following code loops through the array and adds the name of each value to a ListBox.
|
|
For Each hatch_style As HatchStyle In _
[Enum].GetValues(GetType(HatchStyle))
lstHatchStyles.Items.Add(hatch_style.ToString)
Next hatch_style
|
| |
|
| |
|
|