Re: [Enum]



That's pretty sweet, Mike. Thanks for sharing this...I learned something
new. :-)

- Kev

"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:OjQf$hmnIHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
|
| "Lorin" <Lorin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:257FD457-146C-4C3C-B9FC-3E607B0DE91D@xxxxxxxxxxxxxxxx
| > VB6SP6
| > Where can I find an explaination of the usage of [] in an Enum?
| >
|
| As far as I know, it's undocumented. However, what the brackets do is
make that member of the Enum type hidden. For example, I
| frequently do something like this:
|
| Public Enum SortTypeConstants
| [_Min] = 1
| elvInt = 1
| elvFloat = 2
| elvCurrency = 3
| elvDate = 4
| elvCustom = 5
| elvTextBinary = 6
| elvTextStd = 7
| [_Max] = 7
| End Enum
|
| And then in a Let property procedure:
|
| Public Property Let SortType(ColumnIndex As Long, SortType As
SortTypeConstants)
|
| 'If outside the range of valid values, use the same type of sorting
| 'that is standard for a ListView
| If SortType < [_Min] Or SortType > [_Max] Then
| SortType = elvTextStd
| End If
|
| On Error GoTo EH
|
| m_SortType(ColumnIndex) = SortType
|
| Exit Property
|
| EH:
|
| If Err.Number = 9 Then
| 'If we get a subscript out of range error,
| 'we need to redimension the array
| ReDim Preserve m_SortType(ColumnIndex)
| Resume
| End If
|
| End Property
|
| Instead of merely defaulting to a value if the assigned value is out of
range, you might just raise error number 380 (Invalid
| Property Value). The reason I do this is so that if I add members to this
enum, all I have to do is change the value for _Max in the
| enum declaration and not worry about finding every place where this value
has been hard-coded.
|
| Although not required, it's customary to use an underscore as the first
character for the hidden enum member. Also, in Object
| Browser, if you enable the Show Hidden Members option, you'll not only see
these in Object Browser, but in IntelliSense as well.
|
| --
| Mike
| Microsoft Visual Basic MVP
|
|


.



Relevant Pages

  • [PATCH 05/15] drbd: user space interface (based upon connector/netlink)
    ... new file mode 100644 ... This file is part of DRBD by Philipp Reisner and Lars Ellenberg. ... +enum drbd_disconnect_p { ... +#define NL_INTEGER(pn, pr, member) ...
    (Linux-Kernel)
  • [PATCH 06/16] drbd: user space interface (based upon connector/netlink)
    ... new file mode 100644 ... This file is part of DRBD by Philipp Reisner and Lars Ellenberg. ... +enum drbd_disconnect_p { ... +#define NL_INTEGER(pn, pr, member) ...
    (Linux-Kernel)
  • Re: Ruby idiom for enum?
    ... aggregate all the data into the enum member itself. ... class Enum < Module ... def initialize ...
    (comp.lang.ruby)
  • Re: [Enum]
    ... Where can I find an explaination of the usage of in an Enum? ... what the brackets do is make that member of the Enum type hidden. ... Public Property Let SortType(ColumnIndex As Long, ... it's customary to use an underscore as the first character for the hidden enum member. ...
    (microsoft.public.vb.general.discussion)
  • Re: Schon wieder PropertyGrid
    ... aber wie kann ich das Enum dynamisch ... Danke Mike ... >> soll über ein PropertyGrid bearbeitet werden. ... > Du kannst einfach einen enum als Typ von TestProp nehmen: ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)