Category: 

What are Arrays in VBScript?

Article Details
  • Written By: Page Coleman
  • Edited By: Allegra J. Lingo
  • Last Modified Date: 26 November 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The mongoose was introduced to Hawaii in order to kill rats, but mongooses hunt in the day, while rats are nocturnal.  more...

December 7 ,  1941 :  Japanese bombers attack Pearl Harbor.  more...

Arrays in VBScript are functions that create specific kinds of variables which can increase a script’s flexibility. Much like they are used in algebra, variables as they are used in programming are placeholders for values. The algebraic expression x + y = z is an example of the use of variables. In this example, the x may be set to equal any number. Similarly, when using an array, the value of the variable can change, and it does not need to be hard-coded.

VBScript is a Microsoft® scripting language that is related to Visual Basic and Active Scripting, which was originally called ActiveX. Web developers may use VBScript in client-side scripting for the Internet Explorer® browser. It can also be used for server-side scripting in an ASP.Net environment. Windows system administrators may use VBScript because it can be used for interacting with the Windows Component Object Model (COM) as well as for automating some system maintenance tasks.

This scripting language allows for up to 60 positions, or dimensions, to be used in its arrays. Arrays in VBScript begin with the number 0 for element indexing, which indicates the position within the array. The 0 will indicate the first position, the number 1 will indicate the second position, and so on.

Ad

There are two types of arrays in VBScript. The first type is a static array. This is the simplest type. When using this array, the programmer defines the size of the index, which is the maximum number of elements, of the array up front, and it will not change.

A more flexible and useful array type is the dynamic array. A dynamic array allows the size of the array to change as the script is executed. An extension of the dynamic array is a multidimensional array. With this convention, a programmer can establish an array with two or more dimensions.

Regardless of type, VBScript provides a number of functions for use with arrays. These functions ease some common tasks, such as joining or splitting data in arrays. VBScript also offers a loop statement that can be used to move through each element in an array.

Some common programming tasks may make use of the loop function. Arrays in VBScript may be used to export data from one file to another. A script may take data entered on an HTML form, store it in arrays, and then use that data elsewhere on a website. One other useful task involves writing a script to connect to a database, and then to use the array function to display data on a web page or other screen.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email