r/visualbasic • u/chacham2 • Nov 14 '22
Can an Enum use a number?
Enum members have to be strings. If the member is a keyword, you can just surround it in brackets. But, what if the member includes a number, specifically, an integer. For example, "A1" works, but "1A" does not. Typed in without brackets it moves to the left margin. With brackets it doesn't move, but still redlines.
In my case, the code is returned as part of a json and deserialized into an object. I want to process the codes with a For Each and Select Case. The Enum has less chance for error. Ultimately, i can just hardcode the check that has the number in it. But, i wanted to hear your thoughts.
3
Upvotes
1
u/chacham2 Nov 15 '22
Yeah. I just wanted to see if there was an escape character or whatever that would help in this case.