VBScript Tutorials - Herong's Tutorial Examples - Version 5.20, by Dr. Herong Yang

VBScript Tutorials - Herong's Tutorial Examples

http://www.herongyang.com/VBScript/

Copyright © 2015 by Dr. Herong Yang. All rights reserved.

HerongYang.com This free VBScript tutorial book is a collection of notes and sample codes written by the author while he was learning VBScript himself, an ideal tutorial guide for beginners. Topics include Variant, Array, Function, Error Handling, Regular Expression, Dictionary, File System, Class, Object, IE Browser, IIS Server, WSH, Windows Script Host.

Table of Contents

About This Book

Introduction of VBScript - Visual Basic Scripting Edition

What Is VBScript?

Using VBScript with Internet Explorer

Using VBScript with Internet Information Services

Using VBScript with Windows Script Host

Using Visual Basic with Microsoft Access

Variant Data Type, Subtypes, and Literals

"Variant" - Data Type and Subtypes

Data Literals

Data Literal Examples

String Data Literals

Date and Time Data Literals

Arithmetic Operations

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

String Comparison 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

What Is an Expression?

Precedences of Operations

Examples of Expressions

Statement Syntax and Statement Types

What Is a Statement?

Commonly Used Types of Statements

Array Data Type and Related Statements

What Is an Array?

"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

"For Each" Statement 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

Creating a Copy of an Array

"Type mismatch" Runtime Error - Assignments to Array Variables

Conditional Statements - "If ... Then" and "Select Case"

"If" Statements

"If" Statement Examples

"Select Case" Statements

"Select Case" Statement Examples

Loop Statements - "For", "While", and "Do"

"For ... Next" Statements

"For ... Next" Statement Example Examples

"While" Statements

"While" Statement Examples

"Do ... Loop" Statements

"Function" and "Sub" Procedures

What Is a Procedure?

"Function" Statement and Function Call

Function Procedure Example

"Sub" Statement and Subroutine Call

Sub (Subroutine) Procedure Example

Passing Arguments to Procedures

Example - Passing Arguments by Reference

Example - Passing Arguments by Value

Passing Arrays as Arguments

Variable Scope in Procedures

Example - Variable Scope in Procedures

Built-in Functions

Built-in Math Functions

Built-in Conversion Functions

Built-in String Functions

Built-in Date and Time Functions

Built-in Array Functions

Built-in Misc. 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

Error Handling Rules Overview

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

Creating Your Own Classes

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 Codes with HTML "script" Tags

Including VBScript Codes as External Files

DOM API - The "document" Object

DOM API - The "window" Object

Event Listeners and Objects

'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)

WSH (Windows Script Host)

What is WSH (Windows Script Host)?

"csript.exe/wscript.exe" Command Version and Options

Running VBScript Code Files

"WScript" Runtime Object Hierarchy

"oShell.Exec(cmd)" - Running System Command with a Script

WSF - Windows Script File XML Format

References

Printable Copy - PDF Version

Keywords: VBScript, VB, Script, Tutorial, Example, Sample, Free, Book

Table of Contents - Updated in 2015, by Dr. Herong Yang