A sub is a named procedure that performs one or more operations without returning a value to its caller. You define a sub by specifying a series of one or more statements that are to be executed as a block and enclose these statements between the sub signature and the End Sub statement. You can't include a statement that assigns the sub a value.

A sub signature specifies the sub name, its scope, the sorts of values that it expects the application to pass it (if any), and the lifetime of the variables that it defines (if any).

You can define a sub at module level or as a member of a user-defined class. Declaring a sub before you define it lets you refer to that sub before you actually define it. You use the Declare statement to explicitly declare a sub as a member of a user-defined class or at module level in a product that does not support the Integrated Development Environment (IDE). The IDE automatically generates a Declare statement for each sub that you define at module level, so you should not include any.

For information on the four specialized kinds of sub that you can define--Sub Initialize, Sub Terminate, Sub New, and Sub Delete, see "Specialized subs" later in this chapter.