Get an enum value assigned with *concatenated* string

T

Tetsuya Oguma

Hi everyone,

Thanks for Joel and Sheeloo for my previous post.

I want to now concatenate a name of enum item and get its value.

So, an example is:

Enum Periodicity
abcWeekly = 52
abcMonthly = 12
abcYearly = 1
End Enum

The reason why I want to do this is 1) get user input of "Monthly" and 2)
add a prefix of "abc" to get a value of "12"!

How can I do that?

I tried Application.Evaluate("abc"&"Monthly"), but in vain...

Thanks in advance!
 
B

Bob Phillips

It has been explained to you already why you cannot use evaluate.

Keep it simple and use say a case statement


Enum Periodicity
Weekly = 52
Monthly = 12
Yearly = 1
End Enum

Select Case UserInput

Case "Weekly": Res = Weekly
Case "Monthly": Res = Monthly
Case "Year": Res = Yearly
End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top