You may have noticed by now that you cannot have a public constant in a user control or class module. You may have also noticed that a lot of parameters in other controls come up with a list of possible values, such as vbCritical for the Icon property of the Msgbox function. To do this in VB, you use Enum statements. These are also the only way to create public constants. Here is a sample Enum:
Public Enum ShowDialogConstants
SDC_ShowOpen = 0
SDC_ShowSave = 1
SDC_ShowPageSetup = 2
End Enum
The assignment of values is optional. In order to use this in a parameter, you specify As ShowDialogConstants instead of the usual As Long etc. Then, when the user of your control reaches that parameter of the function, he/she will get a list of possible constants (listed above), instead of having to remember the actual numbers.
Public Sub ShowDialog(vMethod As ShowDialogConstants)
Select Case vMethod
Case SCD_ShowOpen
'// show open
Case 1 '// the specified numbers can be used too
'// show save
...
End Sub
So, when you come to fill the parameters, you get this:
Comments