Enumerations are basically used to represent numeric constants. But many a times I have felt the need of my enumerations to represent string constants.
Here is one way of how to make this possible. This makes use of the capabilities of the System.ComponentModel namespace.
This is how you define the enum:
(Notice the Description metadata attribute contains the string value we want for the enum)
vb.net Code:
''Put the string value of your enum in the Description metatag.
'' (Dont forget to Import System.ComponentModel)
Public Enum GMCars
<Description("Chevy SRV")> ChevySRV
<Description("Chevrolet aveo")> ChevroletAveo
<Description("Chevrolet Optra")> ChevroletOptra
<Description("Chevrolet Opel GT")> ChevroletOpelGT
<Description("Chevrolet Magnum Optra")> ChevroletMagnumOptra
<Description("Chevrolet Tavera")> ChevroletTavera
<Description("Chevrolet Tavera Neo")> ChevroletTaveraNeo
<Description("Chevrolet aveo U-VA")> ChevroletAveoUVA
<Description("Opel Astra")> OpelAstra
<Description("Opel Corsa")> OpelCorsa
<Description("Opel Corsa Swing")> OpelCorsaSwing
<Description("Chevrolet Captiva ")> ChevroletCaptiva
<Description("Chevrolet Malibu ")> ChevroletMalibu
End Enum
Now put this function in any module, so that it is accessible through the application:
vb.net Code:
''This procedure gets the <Description> attribute of an enum constant, if any.
''Otherwise it gets the string name of the enum member.
Public Shared Function EnumDescription(ByVal EnumConstant As [Enum]) As String
Dim fi As Reflection.FieldInfo = EnumConstant.GetType().GetField(EnumConstant.ToString())
Dim aattr() As DescriptionAttribute = DirectCast(fi.GetCustomAttributes(GetType(DescriptionAttribute), False), DescriptionAttribute())
If aattr.Length > 0 Then
Return aattr(0).Description
Else
Return EnumConstant.ToString()
End If
End Function
OK so now we are ready to use our setup with string values.
Now each enum member contains a string value attached with it and we can get it using our EnumDescription function wherever we want the String value. Otherwise we would use it as we would use any other enum which represents numeric constants.
Let’s fill it into a listbox for example:
vb.net Code:
ListBox1.Items.Add(EnumDescription(GMCars.ChevySRV))
ListBox1.Items.Add(EnumDescription(GMCars.ChevroletOptra))
ListBox1.Items.Add(EnumDescription(GMCars.ChevroletOpelGT))
ListBox1.Items.Add(EnumDescription(GMCars.ChevroletAveoUVA))
ListBox1.Items.Add(EnumDescription(GMCars.OpelAstra))
Note that we no longer need to type the actual string values, but instead use the Enum members.
The advantage you get with this method is the same as what you get with normal enums that represent numbers. You do not have to type the actual numeric value wherever you use it. Same way you do not need to type the String values in this case wherever you use this enum.
In the above code sample I have used the procedure name "EnumDescription" to explain things here better, that makes the code lines look longer. But in actual practice I use very short notation (e.g. ED) so that it is hardly noticable. So the code line reduces to something like:
vb.net Code:
ListBox1.Items.Add(ED(GMCars.ChevySRV))
Really easy. Isn't it? 
Pradeep