Re: Enum Names

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks


"NickHK" <TungCheWah@xxxxxxxxxxx> wrote in message
news:uAlnatX$GHA.5068@xxxxxxxxxxxxxxxxxxxxxxx
As Bob says, these do not really exist in compiled code, as they have been
replaced with their values, the same as a Const is.
Not sure if this is strictly a correct example, but..
You can use them when you set a value :
ActiveCell.Borders(xlEdgeBottom).LineStyle = xlDashDot
but when retrieving the value :
?ActiveCell.Borders(xlEdgeBottom).LineStyle
4

not xlDashDot

Using Chip's method, you are querying the Type Library for the enum's
value,
not the compiled code.

You can link the enum values to an arry of string though

Dim MyEnumString(1 to 2) as string

MyEnumString(firstKey)="firstKey"
MyEnumString(secondKey)="secondKey"

as long as you enum is compiled before your array elements are assigned.
Depends why you need to do this, as the actual name of the enum element
does
not have any real meaning as it's only to aid your memory. It's the
numeric
value that matters.

NickHK

"Goofy" <me@xxxxxxxx> wrote in message
news:ueFqOiO$GHA.4544@xxxxxxxxxxxxxxxxxxxxxxx
how can I retreive the string value of the enum internal identifier, in
other words if I have a value of 2 I want the corresponding "secondKey"


Public Enum MyEnum

firstKey = 1
secondKey = 2

End Enum






.



Relevant Pages

  • Re: enums: What the H? again
    ... > find no sign of it in the Enum class until I did a decompile and saw ... > private String shortName; ... > private static InDir currentState = UNKNOWN; ...
    (comp.lang.java.programmer)
  • Re: enums: What the H? again
    ... Everything comes clear when you decompile an enum, ... private String shortName; ... private static InDir currentState = UNKNOWN; ...
    (comp.lang.java.programmer)
  • A Class to get the name of Enum constant at runtime
    ... Dim rs As ADODB.Recordset ... You can get the description of an Enum form it's value. ... EnumName As String, ... Dim Idx As Long ...
    (microsoft.public.vb.general.discussion)
  • EnumConverter interfering with Designer-Generated Code
    ... string representations of an enum's values. ... every enum whose values I desire to be displayed as localized ... "ShortDistance" but the Designer-Generated code looks like this: ... Design-Time or at Run-Time (so that I can use the localization ...
    (microsoft.public.dotnet.languages.csharp)
  • EnumConverter interfering with Designer-Generated Code
    ... string representations of an enum's values. ... every enum whose values I desire to be displayed as localized ... "ShortDistance" but the Designer-Generated code looks like this: ... Design-Time or at Run-Time (so that I can use the localization ...
    (microsoft.public.vsnet.ide)