ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get an enum value assigned (https://www.excelbanter.com/excel-programming/418800-get-enum-value-assigned.html)

Tetsuya Oguma

Get an enum value assigned
 
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

joel

Get an enum value assigned
 
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)

"Tetsuya Oguma" wrote:

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


Sheeloo[_3_]

Get an enum value assigned
 
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...
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Tetsuya Oguma" wrote:

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



All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com