Object Variables

At this point, you've seen a variable that contains a single value. When you have a variable such as TotalSales = 0, then TotalSales is a normal variable and generally contains only a single value. It is also possible to have a more powerful variable called an object variable. An object variable holds many values, basically, any property that is associated with the object is associated with the object variable.

I generally do not take the time to declare my variables. Many books implore you to use the DIM statement to identify all your variables at the top of the procedure. This allows you to specify that a certain variable is of a certain type, such as Integer or Double. Although this saves a tiny bit of memory, it requires you to know up front which variables you plan on using. I tend to invent variables as I go, whipping up a new variable on the fly as the need arises. However, there are great benefits to declaring object variables. The VBA

0 0

Post a comment