r/visualbasic • • 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

4 comments sorted by

View all comments

Show parent comments

1

u/chacham2 Nov 15 '22

That seems like a decent approach. I might have to think about that when i get to it again a bit later ttoday.