Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1 ) it'sEnum With description

VB.NET
Public Enum ActionDrug_list
        <Description("Drug withdrawn")> Drug_withdrawn = 1
        <Description("Drug reduced")> Drug_reduced = 2
        <Description("Drug increased")> Drug_increased = 3
        <Description("Dose not changed")> Dose_not_changed = 4
        <Description("Unknown")> Unknown = 5
        <Description("Not applicable")> Not_applicable = 6
    End Enum 


2) Method For Calling by passing Enum type

VB.NET
Public Function GetActionDrugList(Nodevalue As String, type As ConversionTYpe) As String
       Dim ActionDrug As ActionDrug_list

       Return GetStringvalue(ActionDrug, Nodevalue)

    End Function 


3) Method For getting Descrption value

VB.NET
Private Function GetStringvalue(ByVal EnumName As [Enum], ByVal cmpvalue As String) As String
       Dim items As Array

       Dim Type_ = EnumName.GetType()
       items = System.Enum.GetValues(EnumName.GetType())

       For Index = 0 To items.Length
           Dim description As String = GetEnumDescription(DirectCast(Index, EnumName.GetType()))
       Next Index
       Return ""
   End Function

But here i am uanble To pass Enumname for GetEnumDescription line
VB.NET
Dim description As String = GetEnumDescription(DirectCast(Index, EnumName.GetType()))

it's Show That EnumName is Not the valid type even I triyed Get type from it via
VB.NET
EnumName.GetType()

is there any way to Do that?

What I have tried:

VB.NET
Dim description As String = GetEnumDescription(DirectCast(Index, EnumName.GetType()))
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900