Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

CHAPTER 3 INTRODUCTION TO ACCESS VBA > VARIABLES AND BEGINNING DATA TYPES - Pg. 70

70 Microsoft Access VBA Programming for the Absolute Beginner, Fourth Edition F IGURE 3.9 Attempting to use the Text property to retrieve user input from text boxes. V ARIABLES AND B EGINNING D ATA T YPES Paramount in any programming language is the concept of variables. In a nutshell, vari- ables are pointers to storage locations in memory that contain data. You often hear variables referred to as containers for data. In reality they are pointers that represent a memory address pointing to a memory location. Though every variable created is unique (unique memory address), all variables share some common characteristics: · Every variable has a name. · Each variable has an associated memory address (hidden in modern programming lan- guages such as VBA). · Variables have a data type such as String , Integer , or Boolean . Variables in Access VBA must begin with a letter and cannot be longer than 255 characters, nor can they contain periods or spaces. When created, variable names point to a location in memory that can be managed during the execution of your program. Demonstrated next, VBA programmers use the Dim keyword (short for dimension) to declare a new variable in what's called a declaration statement: Dim myVariable Once a variable has been declared, VBA reserves space in memory so you can store and retrieve data from its memory location using VBA statements. Simply declaring variables is not the end of the road. It is good programming practice to tell VBA what kind of variable, the