R
R Avery
I have the problem right now that i wish i had a function to convert a
number of a particular enum to string (e.g.,
ADODB.DataTypeEnum.adDBTimeStamp to "adDBTimeStamp"). It should be
possible to automatically generate these conversion functions.
I know it is possible using some complicated object library that i
forget the name to scan a type library and programmatically iterate
over interfaces, methods of interfaces, etc, and i believe can read
enums. Therefore, a perfect application of this object library would
be to create the functionality that I discussed above. All i would
have to do is pass the path of the DLL or TLB file, and the name of the
enum, and the function would return the conversion functions.
Has anyone done this? Any help would be appreciated.
For example, it should automatically accept an Enum like this:
Public Enum cbfPhase
cbfNotAPhase
cbfNotStarted
cbfParsed
cbfBeta
cbfData
cbfDone
End Enum
And turn it into these:
Public Function cbfPhaseToString(ByVal Value As cbfPhase) As String
' Method for converting cbfPhase values into a String.
Select Case Value
Case cbfNotAPhase
cbfPhaseToString = "NotAPhase"
Case cbfNotStarted
cbfPhaseToString = "NotStarted"
Case cbfParsed
cbfPhaseToString = "Parsed"
Case cbfBeta
cbfPhaseToString = "Beta"
Case cbfData
cbfPhaseToString = "Data"
Case cbfDone
cbfPhaseToString = "Done"
End Select
End Function
Public Function StringTocbfPhase(ByVal Value As String) As cbfPhase
' Method for converting a String into cbfPhase.
Select Case Value
Case "NotAPhase"
StringTocbfPhase = cbfNotAPhase
Case "NotStarted"
StringTocbfPhase = cbfNotStarted
Case "Parsed"
StringTocbfPhase = cbfParsed
Case "Beta"
StringTocbfPhase = cbfBeta
Case "Data"
StringTocbfPhase = cbfData
Case "Done"
StringTocbfPhase = cbfDone
End Select
End Function
number of a particular enum to string (e.g.,
ADODB.DataTypeEnum.adDBTimeStamp to "adDBTimeStamp"). It should be
possible to automatically generate these conversion functions.
I know it is possible using some complicated object library that i
forget the name to scan a type library and programmatically iterate
over interfaces, methods of interfaces, etc, and i believe can read
enums. Therefore, a perfect application of this object library would
be to create the functionality that I discussed above. All i would
have to do is pass the path of the DLL or TLB file, and the name of the
enum, and the function would return the conversion functions.
Has anyone done this? Any help would be appreciated.
For example, it should automatically accept an Enum like this:
Public Enum cbfPhase
cbfNotAPhase
cbfNotStarted
cbfParsed
cbfBeta
cbfData
cbfDone
End Enum
And turn it into these:
Public Function cbfPhaseToString(ByVal Value As cbfPhase) As String
' Method for converting cbfPhase values into a String.
Select Case Value
Case cbfNotAPhase
cbfPhaseToString = "NotAPhase"
Case cbfNotStarted
cbfPhaseToString = "NotStarted"
Case cbfParsed
cbfPhaseToString = "Parsed"
Case cbfBeta
cbfPhaseToString = "Beta"
Case cbfData
cbfPhaseToString = "Data"
Case cbfDone
cbfPhaseToString = "Done"
End Select
End Function
Public Function StringTocbfPhase(ByVal Value As String) As cbfPhase
' Method for converting a String into cbfPhase.
Select Case Value
Case "NotAPhase"
StringTocbfPhase = cbfNotAPhase
Case "NotStarted"
StringTocbfPhase = cbfNotStarted
Case "Parsed"
StringTocbfPhase = cbfParsed
Case "Beta"
StringTocbfPhase = cbfBeta
Case "Data"
StringTocbfPhase = cbfData
Case "Done"
StringTocbfPhase = cbfDone
End Select
End Function