Visual Basic and Visual FoxPro constants
VBA
Const
|
VFP
#DEFINE, #UNDEF, #INCLUDE
|
Visual Basic Syntax Notes
Constants in Visual Basic can be Private (the default) or Public and can
optionally be defined as having a data type:
Public Const VAT_RATE As Single = 0.175
Visual Basic for Applications has a wide range of useful system constants such as vbBlue
built into the language. Use the Object Browser from the
menu in the Visual Basic window to search for
constants.
Visual FoxPro Syntax Notes
Constants in Visual FoxPro are neither Public nor Private in the normal sense of the
terms. They exist from the moment that they are created with #DEFINE until the moment
that they are released with #UNDEF:
#DEFINE CTRL_C 3
* CTRL_C now exists in all
* the lines of FoxPro code
* which may be in several different modules
* until it is undefined like this:
#UNDEF CTRL_C
Do not try to put an '=' sign into the declaration of the constant.
Visual Foxpro include files
FoxPro also has the #INCLUDE directive which pulls a header file of
constants into the program. This makes maintenance easier because you can then keep all
the constants for a project in one external file rather than having to cut and paste the
#DEFINE statements into every module.
The FoxPro.H file supplied with the language includes the definitions of many useful
constants such as COLOR_BLUE. Unlike Visual Basic, these are not built into the language
itself.
A form or a class can also use a constant file. Rather than using the #INCLUDE statement
you select from the
or menu as
appropriate. You can also set up the FoxPro options to specify a default include file.
It is possible to chain these include statements so that a project may have an include
file which itself pulls in the standard FoxPro.H:
#INCLUDE FoxPro.H
#DEFINE NOENTRIES "-None-"
#DEFINE ALLENTRIES "-All- "
#DEFINE APP_FALSE "False"
#DEFINE APP_TRUE "True"
Comments
|
Language index
|
Variables
|