Friday 10, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

Arrays

The VBScript language provides support for arrays. You declare an array using the Dim statement, just as you did with variables:

Dim States(50)

The statement above creates an array with 51 elements. Why 51? Because VBScript arrays are zero-based, meaning that the first array element is indexed 0 and the last is the number specified when declaring the array.

You assign values to the elements of an array just as you would a variable, but with an additional reference (the index) to the element in which it will be stored:
States(5) = "California"
States(6) = "New York"

Arrays can have multiple dimensions-VBScript supports up to 60. Declaring a two dimensional array for storing 51 states and their capitals could be done as follows:

Dim StateInfo(50,1)
To store values into this array you would then reference both dimensions.

StateInfo(18,0) = "Michigan"
StateInfo(18,1) = "Lansing"

VBScript also provides support for arrays whose size may need to change as the script is executing. These arrays are referred to as dynamic arrays. A dynamic array is declared without specifying the number of elements it will contain:

Dim Customers()

The ReDim statement is then used to change the size of the array from within the script:
ReDim Customers(100)

There is no limit to the number of times an array can be re-dimensioned during the execution of a script. To preserve the contents of an array when you are re-dimensioning, use the Preserve keyword:
ReDim Preserve Customers(100)

 
     
   
VBScript Tutorial
 
  Introduction
Introduction
  How to
How to
  Where to
Where to
  Working With Variables
Working With Variables
  Arrays
Arrays
  VBScript Procedures
VBScript Procedures
  Conditional Statements
Conditional Statements
  For Next Loop
For Next Loop
  While Loop
While Loop
  Comments
Comments
  Date
Date
  MsgBox
MsgBox
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download Pay Per Click Marketing Guide Ebook Pay Per Click Marketing Guide
   
Download Computer Basics Ebook Computer Basics
   
Download Algorithm and Complexity  Ebook Algorithm and Complexity
   
Download An Insiders Guide To Writing Articles Ebook An Insiders Guide To Writing Articles
   
Download How To Get Rich From Any MLM Program Ebook How To Get Rich From Any MLM Program
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz