zwei kleine Funktionen, um
1. die EnumMember Namen anhand eines Enum Wertes zu ermitteln und
2. den Enum Wert anhand eines EnumMember Namens zu ermitteln
<FlagsAttribute()> _
Public Enum EAccessType As Integer
change = 1
insert = 2
delete = 4
move = 8
copy = 16
End Enum
' ermittelt die EmumMember Namen
' Bsp: ist Value 7 (change AND insert AND delete) ist das Ergebnis {"change", "insert", "delete"}
Public Function GetEnumItemNames( _
ByVal Value As EAccessType) As String()
Dim a As String
Dim b As String
Dim c As String()
a = Value.ToString
a = a.Replace(" ", "")
c = Split(a, ",")
a = ""
For Each b In c
If a <> "" Then a &= ","
a &= GetEnumValue(b)
Next
c = Split(a, ",")
Return c
End Function
' Ermittel den EnumMember Wert anhand dessen Namen
Private Function GetEnumValue(ByVal strName As String) As EAccessType
Enum.Parse(EAccessType.GetType(), strName) ' @_ntr_: danke ;-)
End Function
2 Kommentare zum Snippet