Dennis,
Have you looked at the shared functions on System.Enum?
You can use either Enum.ToObject or Ctype to convert an integer into the
corresponding Enum value.
You can use ToString or Enum.GetName to convert a corresponding Enum value
into a String.
You can use Enum.Parse to convert a string into the corresponding Enum
Value.
Dim anInteger As Integer = 6
Dim aMyData As myData
Dim aString As String
aMyData = DirectCast([Enum].ToObject(GetType(myData), anInteger),
myData)
aMyData = Nothing
aMyData = CType(anInteger, myData)
aString = aMyData.ToString()
aString = Nothing
aString = [Enum].GetName(GetType(myData), aMyData)
aMyData = Nothing
aMyData = DirectCast([Enum].Parse(GetType(myData), aString), myData)
There are a number of other useful shared methods on System.Enum, such as
Enum.GetValues to get the list of values defined on an Enum, Enum.GetNames
to get the list of names, and Enum.IsDefined to verify the enum value is one
of the defined values (taking the Flags attribute into effect).
Note, [Enum] says to treat Enum as an identifier (as in System.Enum) instead
of as a keyword (as in "Public Enum myData").
Hope this helps
Jay
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
I have an enum as follows:
Public Enum myData
FirstData = 6
SecondData = 7
end enum
Is there anyway that I can return the Enum names by their value, i.e., I
want to input 6 into a function and return the name "FirstData"
Thanks.
--
Dennis in Houston