• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

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:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint