I am trying to write a function that will convert an enum value to english.
I can easily do this line be line, but a function would be the better solution.
For example:
Public Enum UpdateEnum
No_Update_Required = 0
WebSite_Needs_Update = 1
Internal_Needs_Update = 2
End Enum
Public Enum EmailComparisonEnum
WebSiteEmailRequiresUpdate = 0
InternalEmailRequireUpdate = 1
NoUpdateRequired = 2
End Enum
Now I can easily convert an enum numeric value into english using the following code:
EmailStatus = [Enum].GetName(GetType(EmailComparisonEnum), EnumVariable)
Let's say that EnumVariable = 2. Then Email Status would be assigned with "NoUpdateRequired".
Since doing this line by line, every time I need to convert an enum to English would look cumbersome and (important) I have several enum types; I want to create a function to do this.
My current function:
Private Function ConvertEnumValueToEnglish(EnumType As Type, Value As Integer) As String
ConvertEnumValueToEnglish = [Enum].GetName(GetType(EnumType), Value)
End Function
But so far I cannot figure out how to do this.