4.2. Variables and VBA Syntax

This section explores some fundamentals you need to know in order to successfully program in VBA. We'll go through them relatively quickly as most of them need only to be recapitulated. If you need more information about any of these topics, you might want to purchase a beginner's guide to VBA programming, such as VBA For Dummies, by John Paul Mueller (Wiley Publishing, Inc., ISBN: 0764539892).

4.2.1. Variables

One of the most important concepts in programming is the use of variables. A variable is a location in memory where you can store a value while your code is running. Throughout your code you'll need to declare, change, and fill variables. These variables will hold a variety of different types of data including strings, numbers, and objects. You use a variable in order to save time. For example, if you need to specify a particular state repeatedly in your code, it can be much faster and cleaner to create a variable strState than to repeatedly use "Maine" in your code. If you ever need to switch states and use California instead, all you have to do is change the value of your variable rather than find all the instances of Maine in your code. Declaring variables properly is likely one of the most important tasks you'll need to master to program in VBA. It's not hard, and we'll cover the major rules and recommendations in the next few sections. Types of Variables

In VBA, you can declare many different types of variables. Each type of ...

Get Access 2003 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.