VBScript Tutorials - Herong's Tutorial Examples - v6.02, by 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
Introduction of VBScript - Visual Basic Scripting Edition
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
►"Function" and "Sub" Procedures
"Function" Statement and Function Call
"Sub" Statement and Subroutine Call
Sub (Subroutine) Procedure Example
Passing Arguments to Procedures
Example - Passing Arguments by Reference
Example - Passing Arguments by Value
Example - Variable Scope in Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
IE Web Browser Supporting VBScript