To declare a constant you use the following syntax:
Scope Const ConstantName As DataType = Value
Scope represents the range of the variable. ConstantName is a string representing the name of the variable. DataType represents what sort of data is stored in the variable. Value is the value of the constant. For example,
Public Const MissingDiskMsg As String = "Disk not ready. Please
insert a disk"
if declared in the General Declarations section of a form, MissingDiskMsg can be accessed in all procedures in that form. So
Msgbox MissingDiskMsg, vbOKOnly
Displays a message box saying Disk not ready. Please insert a disk.
Simple!
Comments