Access constants programmatically?

Hi, is it possible to access constants programmatically?

I have a long list of commands the user can pick from a popup menu. Each item relates to the name of a constant in my class. Since there are lots of them I would like to avoid a huge select statement with something like…

MyClass.Constants.value(MyPopupMenu.Text)

Is this kind of thing possible?

No.

No. You should use a shared method. Pass a string, and return the desired value. Constants can’t be dictionaries.

Thanks for the quick response Greg and Rick, I really appreciate it.

I guess constants are compile time only then.

I guess I’ll hold a Dictionary instead so I can look them up at runtime and forfeit code completion.

Yes, constants should be just labels for values to be substituted at compile time. So:

Const name1 = “rick”

msgBox name1 // is the same as msgBox “rick”

Many thanks Rick, understood. I’m going down the shared Dictionary property route.

One idea: https://drive.google.com/file/d/0B6w6JZen_vW2Mnh0VmpVbFZxV0k/edit?usp=sharing

Hi Rick, this is more or less where I was going - but you have introduced me to Static - which I didn’t know existed.

Many thanks!!!