Beginning ActiveX - Part 2
Enumerations, usually known as enums allow you to make full use to VB's auto-suggest features. They allow you to group constants together, so that VB will automatically suggest and complete when you set the value.
The enum must first be defined in the declarations section. You can manually specify values for each member, as shown for the Right member, or let VB automatically number them. The value assigned is either zero (if it is the first member), or 1 greater than the value of the immediately preceding membername (Phew!-Ed).
Public Enum eDirection Left Right = 1 Up Down End Enum
To use this enum, just declare the property as the name of the enum:
Public Property Get Direction() As eDirection Direction = m_Direction End Property Public Property Let Direction(ByVal New_Direction As eDirection) m_Direction = New_Direction PropertyChanged "Direction" End Property
That is all there is to it. Use of this feature often seperates a very good control from a professional looking control. You can use it on the borderstyle and backstyle porperties, as with VB's controls.
Page 4 of 7
This article was originally published on November 20, 2002