VBScript Tutorials - Herong's Tutorial Examples - Version 5.23, by Dr. Herong Yang
What Is a Procedure?
This section describes what is a procedure and what are the two types of procedures in VBScript.
Procedure - A unit of code defined outside of the main execution code. A procedure will not be executed unless it is invoked by the main execution code or another procedure.
To learn how to use procedures in VBScript, we need to pay attentions in the following areas:
1. How to define a procedure?
2. How to invoke a procedure?
3. How to exchange data between the procedure and the invoking code?
VBScript offers two types of procedures:
1. Function Procedure - A procedure that returns a value explicitly.
2. Sub Procedure - A procedure that does not return any value explicitly.
Here is simple example of defining a function procedure, invoking a procedure, and exchanging data with a procedure:
Function sqrt(x) sqrt = x^0.5 End Function y = sqrt(2)
Table of Contents