Get an enum value assigned

  • Thread starter Thread starter Tetsuya Oguma
  • Start date Start date
T

Tetsuya Oguma

Hi everyone,

Put it simply,

Enum SecurityLevel
IllegalEntry = -1
SecurityLevel1 = 0
SecurityLevel2 = 1
End Enum

How can I get -1 of "IllegalEntry " above, provided I know "IllegalEntry"?

I tried Application.Evaluate("IllegalEntry "), but in vain...

Thanks,
Tetsuya
 
The evaluate function uses the worksheet to perform the calcualtion and the
worksheet will not recognize the enum. Simply use the enumeration

a = IllegalEntry

or

msgbox(IllegalEntry)
 
Sample code
Public Enum SecurityL
illegalentry = -1
SecurityLevel1 = 0
SecurityLevel2 = 1
End Enum
Sub a()
Dim slevel As SecurityL
slevel = illegalentry
MsgBox slevel
slevel = SecurityLevel1
MsgBox slevel
slevel = SecurityLevel2
MsgBox slevel
End Sub

'enum can be declared as the type
'assigned any value from its members
'used as a constant with the value equal to the member assigned...
 

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

Back
Top