download
order  

Enum Builder

 
Prefix Name Vars Items Module OK Cancel Help Accessibility

Visual Basic is full of enumerated constants (types) that make programming easier; the meaning of MsgBox value 4 is obscure but the meaning of the value vbYesNo is obvious. Summing up all possible types, states, roles or whatever entities you're dealing with will help you ascertain that you don't forget some cases, causing bugs in the program. By specifying your own enumerated constants for values used within your own organization you make your own code more reliable and easier to maintain.

By default, enumerated constants hold a series of consecutive longs starting from zero. This example assigns values 0 to 3 to four security levels:

Public Enum sleSecLevels
  sleAdmin
  slePowerUser
  sleUser
  sleGuest
End Enum

The security routines in the rest of the application can now refer to sleAdmin and the other constants instead of their numeric values. The three-letter lower case prefix helps you recognize the constant as part of this enumerated set when you see it in code.

Working with enumerated constants is encouraged by the Select Case from Enum Builder.

You can add a constant to the enumerated type without having to move to the location where it is declared using  Add Constant To Enum

Start this dialog from using Alt-CCE (Code-vb - Constant - new Enum)

Controls:


Prefix

What is specified here is automatically added to both the enumerated type and the individual constants. In the example: sle

Name

Name of the Enumerated Type

Items

Add the constants to be included in this textbox. Each constant on a separate line. The following variants are allowed:

1. Without starting point, as above example. First value is 0

2. With starting point, each entry has integer value one higher then the previous item

mcColorBlue = 37
mcColorRed
mcColorGreen

3. Each a separate constant

mcColorBlue = 37
mcColorRed = 44
mcColorGreen = 135

Module

Module in which the constant is to be placed (only in case of Public accessibility).

OK

Create enumerated type and close dialog.

Cancel

Close dialog without creating enumerated type.

Help

Starts this Help topic

Accessibility

Private Public Default

Determines from which modules in the application the enumerated type is visible.

Private

The enumerated type is visible only from the current module.

Public

The enumerated type is visible only from all modules.

Default

(= public) The enumerated type does not have explicit accessibility.