How to get Enum value programmatically?

danyeungw

Well-known member
Joined
Aug 30, 2005
Messages
73
Programming Experience
10+
I have the following code. Can I cast the strEnum from string to variable, so that I can get the value from Enum RptHierachy? And how?

Enum
RptHierachy As Integer
ProductFamily = 65
Products = 91
Projects = 129
EngFunction = 172
EngTask = 213
End Enum

Sub sGetLabels(ByVal strDrilldownType As String)
Dim strEnum = "RptHierachy." & strDrilldownType
Dim intHierachy as integer =
End Sub

Thanks.
DanYeung

 
Moved to VB.Net General forum.
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] intHierachy [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2](System.Enum.Parse([/SIZE][SIZE=2][COLOR=#0000ff]GetType[/COLOR][/SIZE][SIZE=2](RptHierachy), strDrilldownType))
[/SIZE]

 
Back
Top