Entering Declarations in Code

See Also13XPMHO

Declarations are nonexecutable code statements that name external procedures, constants or variables and define their attributes (such as data type).  You write declarations for forms5272EF or modules2JU32VW.  To enter module-level declarations, go to the Declarations section of the form or module.  To enter global declarations, go to the Declarations section of a module and use the GlobalTDN897 statement for constants and variables.

You can also enter procedure-level declarations.  For whatever code level and technique you use to declare a variable or constant, specific scopingA9DG7V3 rules may apply.  For details on scoping declarations, see Chapter 7, "Variables, Constants, and Data Types," in the Programmer's Guide.

To open the Declarations section for a form

   1. Double-click the form to open the Code windowJ73QNY.

   2. In the Object box, select (General).

     The Procedure boxBK0DPM automatically displays (Declarations).

   3. Enter the declarations you want, following the guidelines5SZA0GX for entering and editing code.

To open the Declarations section for a module

   1. In the Project window183GH18, select the module you want to open and click the View Code button.

   2. In the Procedure box, select (Declarations).

   3. Enter the declarations you want.

 

Note   Visual Basic comes with the file CONSTANT.TXT.  This file specifies system defaults such as colors, key codes, and defaults for properties3MRB2KQ and events1L2S0SZ.  You can load CONSTANT.TXT into any module and modify it to your specifications.

 


See Also

Programmer's Guide:

Chapter 2, "Your First Visual Basic Application".

Chapter 7, "Variables, Constants, and Data Types"