In the following the line "dim Str1 as String = CType(2,Test1). ToString" line of code are working as I expected.
But if I try to wrap the same functionality in a function then the Line "Convert = CType(Number, EnumType).tostr ing" gives me the error: "Type 'Enumtype' is not Defined"
How do I get the Function to work? Anyone knows how to help?
Peter Schwennesen
But if I try to wrap the same functionality in a function then the Line "Convert = CType(Number, EnumType).tostr ing" gives me the error: "Type 'Enumtype' is not Defined"
How do I get the Function to work? Anyone knows how to help?
Peter Schwennesen
Code:
Public Enum Test1 As Integer
FirstNo1 = 1
FirstNo2 = 2
FirstNo3 = 3
End Enum
Public Enum Test2 As Integer
SecondNo1 = 1
SecondNo2 = 2
SecondNo3 = 3
End Enum
Public Function Convert(ByVal Number As Integer, ByVal EnumType As Type) As String
Convert = String.Empty
Convert = CType(Number, EnumType).tostring
End Function
Private Sub Test_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Str1 As String = CType(2, Test1).ToString
Dim Str2 As String = CType(2, Test2).ToString
Dim Result1 As String = Convert(2, GetType(Test1))
Dim Result2 As String = Convert(2, GetType(Test2))
End Sub