Chapter Four

Parameters

Visual Basic parameters may be optional or mandatory. They may require one data type or may accept any kind, including user-defined types, arrays, and enumerated constants (Enums). With such flexibility comes the responsibility to define parameters wisely so that error-causing values are not passed to procedures willy-nilly.

This chapter covers how and when to use named parameters, optional parameters, and data typing in your procedure definitions. Most of these features have been added or refined over the past several versions of Visual Basic. So, while they are not new to most of us, they may not be widely used in the code most of us work on day to day.

NOTE

In this chapter, an argument is a constant, a variable, or an expression that is passed to a procedure. A parameter is the variable that receives the argument when it is passed to the procedure.