Declares the name, arguments, and code that form the body of a Sub procedure.
|
---|
[Public [Default] | Private] Subname [(arglist)]
[statements]
[Exit Sub]
[statements]
End Sub |
Arguments
- Public
Indicates that the Sub procedure is accessible to all other procedures in all scripts.
- Default
Used only with the Public keyword in a Class block to indicate that the Sub procedure is the default method for the class. An error occurs if more than one Default procedure is specified in a class.
- Private
Indicates that the Sub procedure is accessible only to other procedures in the script where it is declared.
- name
Name of the Sub; follows standard variable naming conventions.
- arglist
List of variables representing arguments that are passed to the Sub procedure when it is called. Commas separate multiple variables.
- statements
Any group of statements to be executed within the body of the Sub procedure.
The arglist argument has the following syntax and parts:
[ByVal | ByRef] varname[( )]
Arguments
- ByVal
Indicates that the argument is passed by value.
- ByRef
Indicates that the argument is passed by reference.
- varname
Name of the variable representing the argument; follows standard variable naming conventions.
Remarks
Requirements
See Also