VBScript Tutorials - Herong's Tutorial Examples - v6.03, by Herong Yang
VBScript Tutorials - Herong's Tutorial Examples
https://www.herongyang.com/VBScript
Copyright © 1998-2024 Herong Yang. All rights reserved.
This VBScript tutorial book is a collection of notes and code samples written by the author while he was learning VBScript (Visual Basic Scripting Edition) himself. Topics include: The Variant Data Type with Subtypes; Fixed-Size and Dynamic-Size Arrays; Function Arguments Passed by References and by Values; Raising and Catching Runtime Errors; Regular Expression and Pattern Match; Runtime DLL Library: Dictionary, File System, and File I/O; Defining Classes with Properties and Default Method; Object Initializing and Terminating Processes; Client-Side Scripting: VBScript Code for IE Browser; Server-Side Scripting: VBScript code for IIS Server; System Admin Scripting: Windows Script Host (WSH). Updated in 2024 (Version v6.03) with minor changes.
Table of Contents
Introduction of VBScript - Visual Basic Scripting Edition
Using VBScript with Internet Explorer 10 or Older
Using VBScript with Internet Explorer 11
Using VBScript with Internet Information Services
Using VBScript with WSH (Windows Script Host)
Using Visual Basic with Microsoft Access
VBScript and Supporting Environments
Variant Data Type, Subtypes, and Literals
"Variant" - Data Type and Subtypes
Introduction of Arithmetic Operations
"+" - Arithmetic Addition Operation
"-" - Arithmetic Subtraction Operation
"*" - Arithmetic Multiplication Operation
"/" - Arithmetic Division Operation
"\" - Arithmetic Integer Division Operation
"Mod" - Arithmetic Modulus Operation
"^" - Arithmetic Exponentiation Operation
Numeric Comparison Operations and Logical Operations
Introduction to Numeric Comparison Operations
Introduction to Logical Operations
String Operations - Concatenation and Comparison
String Concatenation Operation
Variable Declaration and Assignment Statement
Variable Declaration and "Dim" Statement
Assigning Values to Variables - "=" Statement
Empty - The Default Value of a Variable
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Commonly Used Types of Statements
Array Data Type and Related Statements
"Dim x()" - Declaring Array Variables
"x(i)" - Accessing Array Elements with Indexes
"Dim x(n)" - Fixed-Size Array Example
"Dim x()" - Dynamic-Size Array Example
"Erase" Statement - Removing All Elements in an Array
Data Type "Variant()" - Array of Variant Values
Array References and Array Assignment Statements
Assigning an Array to a Scalar Variable
Array References Work Like Arrays
"Array()" Function - Returning a Scalar Reference of an Array
"Type mismatch" Runtime Error - Assignments to Array Variables
Conditional Statements - "If ... Then" and "Select Case"
"Select Case" Statement Examples
Loop Statements - "For", "While", and "Do"
"For ... Next" Statement Example Examples
"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
Built-in Date and Time Functions
Inspecting Variables Received in Procedures
Variable Inspection - Data Type Validation
GetVarInfo() - Variable Inspection Example
GetInteger() - Crash-Free Integer Conversion
Error Handling Flag and the "Err" Object
IE Option Setting - Enable Script Debugging
"On Error Resume Next" - Turning on Error Handling
"On Error GoTo 0" - Turning off Error Handling
"Err.Number" and "Err.Clear()" - Error Code and Clear Method
Built-in "Err" Object Properties and Methods
"Err.Raise()" - Raising Your Own Errors
Regular Expression Pattern Match and Replacement
"RegExp" Class and Object for Regular Expression Support
"MatchCollection" and "SubMatches" Collection Objects
"Set oRegExp = New RegExp" - Creating RegExp Objects
Example of Regular Expression Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
Scripting Runtime DLL Library Overview
"Dictionary" Objects to Store Keys and Values
"FileSystemObject" Objects to Manage File Systems
"Drive" Objects Representing Disk Drives
"Folder" Objects Representing File Folders
"File" Objects Representing Files
"TextStream" Objects Representing File Input and Output
Class, Property, Method and Related Statements
"Class" Statement - Defining Your Own Class
"New" Operator and "Nothing" Object
"Public/Private" Variables and Dot Operator
"Property Let/Set/Get" Procedures
Object Methods - "Public" Procedures
"New", "Set", "Is", ".", "Nothing" - Object Operations
"StringBuffer" - A Class Example
IE Web Browser Supporting VBScript
VBScript Support in IE Web Browsers
Including VBScript Code with HTML "script" Tags
Including VBScript Code as External Files
DOM API - The "document" Object
'vbscript:' Pseudo-URL Addresses
IIS ASP Server Supporting VBScript
What is ASP (Active Server Pages)?
Static, Client-Side and Server-Side Scripting Pages
Setting Up IIS to Run ASP Pages - asp.dll
ASP Objects: Request, Response, Session and Application
ASP Object Example - Passing Values between Pages
Interacting with External Applications - ActiveX Data Object (ADO)
What is WSH (Windows Script Host)?
"cscript.exe/wscript.exe" Command Version and Options
"WScript" Runtime Object Hierarchy
"oShell.Exec(cmd)" - Running System Command with a Script
Keywords: VBScript, VB, Script, Tutorial, Example, Sample, Book