In the Real World

At the most basic level, you can think of a memory location in your computer as a sequence of electrical switches that can be on or off. With these two possible conditions we have the basis for the binary language a computer understands (0 for off and 1 for on). The values stored by a programming variable are then just a patterned sequence of switches that are either on or off.

Some languages, such as C or C++, allow the programmer to directly access memory locations of variables. This extends the power of a programming language dramatically, but is not without dangers. For example, if you change the state of the wrong memory location you can easily cause the computer to crash. VBA handles memory management for you, so it is inherently safer than these other languages; however, with this safety you sacrifice some powerful capabilities.

If you are familiar with the built-in functions available in the Excel application, such as SUM(), AVERAGE(), STDEV(), then you already have a basic understanding of how they work. Functions are often (but not always) passed one or more values and they always return at least one value. For example, if I enter the formula =AVERAGE(A2:A10) into cell A11 on a worksheet in the Excel application, I know that the average of the nine values given in the range A2:A10 will be calculated and returned to cell A11. Excel recognizes the AVERAGE keyword in the formula as one of its built-in functions. Excel then calls the function procedure AVERAGE() and passes the range of values specified in parentheses—in this case, 9 values. The function procedure AVERAGE() then calculates the average of the values passed in as parameters and returns the result to the spreadsheet cell containing the formula. In VBA, you can also call function procedures such as Left(), Mid(), and DateDiff(), as you have seen in previous examples. You can even use the built-in functions of the Excel application. Finally, you can create your own function procedures in VBA.

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment