(See <--????? below in Sub Load_Enum for problem).
I have looked and looked ... everyone speaks about
how to use enumerators (thanks) but WHAT TYPE is
it when passing as a parameter?
p_enm As System.Enum doesn't work.
p_enm As Object doesn't work.
p_enm As Type doesn't work.
Don't laugh please - I have tried stuff like:
Dim enm As System.Enum = CType(p_enm, System.Enum)
So what does work? (See <--????? below).
Public Enum enm_cboTest1 As Integer
Completed = 1
Not_Started = 2
End Enum
Public Enum cboTest2 As Integer
Completed = 1
Not_Started = 2
End Enum
Call Load_Enum(enm_cboTest1)
Call Load_Enum(cboTest2 As Integer)
Private Sub Load_Enum(ByVal p_enm As System.Enum) <--?????
Dim names As String() = System.Enum.GetNames(GetType(p_enm))
For i As Integer = 0 To names.Length - 1
Dim myText As String = names(i).Trim.Replace("_", " ")
Dim myValue As p_enm = System.Enum.Parse(GetType(p_enm), names(i))
Dim b1 As Integer = 0
Next
End Sub
Martin H. - 08 Mar 2008 12:54 GMT
Hello Gene,
Private Sub Load_Enum(ByVal p_enm As enm_cboTest1)
...
End Sub
Call Load_Enum(ByVal value As enm_cboTest1)
Best regards,
Martin
> (See <--????? below in Sub Load_Enum for problem).
>
[quoted text clipped - 31 lines]
> Next
> End Sub
Stephany Young - 08 Mar 2008 12:55 GMT
The type you need to pass is System.Type.
Private Sub Load_Enum(ByVal type As Type)
Dim names As String() = [Enum].GetNames(type)
For i As Integer = 0 To names.Length - 1
Dim myText As String = names(i).Trim.Replace("_", " ")
Dim myValue As Object = [Enum].Parse(type, names(i))
Dim b1 As Integer = 0
Next
End Sub
Call Load_Enum(GetType(enm_cboTest1))
Call Load_Enum(GetType(cboTest2))
Note that myValue needs to be declared as System.Object.
> (See <--????? below in Sub Load_Enum for problem).
>
[quoted text clipped - 31 lines]
> Next
> End Sub
Gene Berger - 08 Mar 2008 17:58 GMT
That did it ... THANKS!!!
> (See <--????? below in Sub Load_Enum for problem).
>
[quoted text clipped - 31 lines]
> Next
> End Sub