Using Constants

Variables are defined as placeholders for nonstatic information. When you need a placeholder for static information, create it as a constant. Constants are used for two reasons. One reason is to hold a value referenced numerous times that does not change during the run of the program but may change in the future—for example, a tax rate. Another reason is to make a program more readable. For example, TaxRate is easier to read than .08167.

To declare a constant and set its value, use the Const statement. After a constant has been declared, it cannot be assigned a new value. If you wanted to declare, for example, a constant to store the value of a sales tax, you would use the following statement:

 Const SALESTAX As Long = .06231  ...

Get Special Edition Using Microsoft® Word 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.