54
Using Variables in VBA
As you've seen in the previous two lessons, variables play a critical role in VBA programming and as such, deserve a detailed explanation of the different kinds of variables and how they can be used. Although you have already used variables in many places throughout this book, it is important to discuss the different kinds of variables and what the differences mean in the VBA code. It is important to understand that where and how a variable is declared will determine how it can be used in VBA code. This lesson is devoted to discussing the kinds of variables allowed in VBA and what the differences are between them.
LESSON SETUP
This lesson is designed to provide information about using variables in VBA and the different kinds of variables it provides. You should be familiar with Access databases, creating modules, and the basics of VBA programming to complete this lesson. Otherwise, this lesson does not require any other specific knowledge of Access.
VARIABLES IN VBA
Variables in a programming language are a way of temporarily storing, retrieving, passing, and manipulating data in code. Variables in VBA are typically declared with a data type, called a Class, to denote the kind of data that will be stored in the variable, though explicitly specifying the data type is not required in VBA. When a variable is declared without a type, it is automatically given the type Variant, which can store any type of data by implicitly casting it to the data type of the ...
Get Microsoft® Access® 2010 24-Hour Trainer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.