< Day Day Up > |
So far, nearly all the code that you've seen in this book has been strictly sequential. That is, execution starts at the top of each procedure, continues line-by-line through the procedure, and stops at the end of the procedure. The one exception to this rule that you've seen so far has been in error-handling code.
VBA is capable of more complex patterns of program execution than this, though. To write flexible VBA code, you need to understand the concepts of branching and looping. Branching lets VBA make a decision and then execute one of several statements depending on that decision. Looping lets VBA execute a statement or a set of statements more than once. As you'll see in this chapter, there are several variations on each of those themes. Together, branching and looping structures are referred to as flow-of-control statements, because they determine the order in which your program's executing flows. |
< Day Day Up > |