Procedures are named blocks of code that perform a task. I’ve shown a lot of procedures already and I feel a little bad about waiting this long to define that term. Procedures can have arguments
, which let you pass values in to the procedure from somewhere, and they may return values
through their name. Figure 2-5 illustrates these parts using the
CubeRoot example from Chapter 1.
Visual Basic has four kinds of procedures:
Perform a task but don’t have return values.
Perform a task and return a value as their result.
Figure 2-5. Parts of a procedure
Get or set a value in an object or module.
A special kind of
Subprocedure that respond to events that occur in Excel. Only classes can contain event procedures.
The following sections explain these different types of procedures and how you use them.