There are two types of procedure statements; the Sub procedure and the Function procedure. Both of
these procedure statements are intended to encapsulate a set of statements that provide functionality
that can be repeatedly called, but the difference between the two is how arguments are passed and
results returned.
The Sub procedure is a series of VBScript statements (enclosed by Sub and End Sub statements) that
perform actions but don't return a value as part of the Sub name. A Sub procedure can take arguments
(constants, variables, or expressions that are passed by a calling procedure). A resultant value or set of
values can be returned through the arguments. If a Sub procedure has no arguments, its Sub
statement must include an empty set of parentheses ().
The Function procedure is a series of VBScript statements enclosed by the Function and End
Function statements. A Function procedure is similar to a Sub procedure, but can also return a value
in the Function name. A Function procedure can take arguments (constants, variables, or expressions
that are passed to it by a calling procedure). If a Function procedure has no arguments, its Function
statement must include an empty set of parentheses. A Function returns a value by assigning a value
to its name in one or more statements of the procedure. The return type of a Function is always a
Variant.
No comments:
Post a Comment