I think I am misunderstanding something… (2019R1.1)
An integer should be able to be casted to an enum even if the enum definition does not have a value for that integer defined… I KNOW that was the intended behavior because I argued with a Xojo (well RS) that one should not be able to do that when enums were first introduced…
But I seem to remember at one time I could just do a simple cast but I now seem to need to use CType. Is my memory wrong?
Dim U8 as Uint8 = Uint8(theEnum) ’ Gives type mismatch error
Dim U8 as Uint8 = Uint8(theEnum) ’ Works IF the integer Enum value is one of the values that was defined in teh enum
Dim U8 as Uint8 = Ctype(theEnum, Uint8) ’ Cause a Framework exception in ObjectGlue.h(190) at Runtime for a value not defined in the enum
The framework exception I reported: feedback://showreport?report_id=58596
Is not being able to do a simple cast a bug or is my memory failing!
BTW as I was raising an exception anyway for an undefined value, this just gave me a different exception than I was expecting… getting there was bug on my part… My code should not have put an undefined value into the enum and that is why I was throwing my own exception!!!