Constants


Constants are, in effect, variables that do not change. They hold values that are used over again within your code and effectively provide shorthand for that particular constant value.

You use the same rules to create a constant as you do to create variables, but you cannot assign a new value to it from within your code as you can with a variable.

 Const Path_Name = "C:\temp\" 

This sets up a constant called Path_Name , and it always has the value C:\temp\ . You can use this in your program every time you want to use that particular path .

There are also predefined constants within the Excel object model ‚ you can see these by using the Object Browser, which is covered in Chapter 12. In the Excel object model, all constants begin with the letters ‚“xl ‚½ to denote that they are part of the Excel object model ‚ for example, xlSaveChanges or xlDoNotSaveChanges . The Object Browser also shows the actual value of the constant at the bottom of the browser window.




Excel VBA Macro Programming
Excel VBA Macro Programming
ISBN: 0072231440
EAN: 2147483647
Year: 2004
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net