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

What Is an Array?

This section provides an introduction of what is an array. VBScript supports fixed size arrays and dynamic size arrays.

Like many other programming languages, VBScript supports the concept of array as a built-in data structure with the following features:

  • An array can be used to store a collection of data elements.
  • VBScript supports two types of arrays: fixed size array and dynamic size array
  • A fixed size array is an array declared with a fixed number of elements.
  • A dynamic size array is an array declared with no size. But its size can be dynamically changed later many times.
  • An array must be associated to a variable for referencing.
  • Each element in an array is associated with a unique index number. By default, index number starts from 0.
  • A specific element in an array can be referred by the index number.
  • A number of built-in functions are provided to work with arrays.
  • The "For Each" loop statement is provided as an easy way to loop through all elements in an array.
  • "Erase" statement is provided as a quick way to remove all values from an array.

Other sections of this chapter provide more details on how define an array and how to use an array.

Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 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

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

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

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

 "Function" and "Sub" Procedures

 Built-in Functions

 Inspecting Variables Received in Procedures

 Error Handling Flag and the "Err" Object

 Regular Expression Pattern Match and Replacement

 scrrun.dll - Scripting Runtime DLL Library

 Creating Your Own Classes

 IE Web Browser Supporting VBScript

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)

 References

 Printable Copy - PDF Version

What Is an Array? - Updated in 2015, by Dr. Herong Yang