Interesting question from a dev I’ve know for a long time.
If I have a property that’s an enum, how do I tell that it’s not been set?
And this is a good question.
Because an enum is, at its core, an integer when you declare one and run its always initialized to the default value for an integer – 0.
And so if you use this fact you can actually detect that its been set or cleared.
Simply make you list of enumerated values NOT use 0 as a valid value.
Public Enum myEnum valueName1 = 1 valueName2 = 2 valueName3 = 3 End Enum
And now any time the value is 0 when your code starts to run you can tell any property that is declared to be a myEnum is or is not set by checking
Private Property someProperty as myEnum Sub Open() Handles Open If 0 = Integer(someProperty) Then break // someProperty has never been set or has been deliberately set to 0 End If End Sub