VBScript (or Visual Basic Script) multidimensional arrays enable a programmer to store data in complex matrices. By using multidimensional array a programmer can create a matrix of data rather than a list.
However, before diving into the rather more complex world of VBScript multidimensional arrays it is probably best to consider a simple array first.
A Simple VBScript Array
Simple VBScript arrays are discussed more fully in Windows Scripting: VBScript and Arrays: How to Create Multidimensional and Dynamic Arrays with VBScript, and they give an easy way of storing simple lists:
The output from this can be seen in figure 1 (at the bottom of this article), but arrays can be used for storing more than simple lists.
A Two Dimensional Array
If a simple VBScript array is analogous to a list then a two dimensional array is analogous to a grid of data (and is often referred to as a rectangular array). Here a 5 by 8 grid is defined:
It's always worth remembering that an array starts with index number 0 and not 1. Bearing that in mind the contents of the array can now be accessed:
It's worth noting the fact that the dimension number is used here with ubound in order to obtain the number of elements in the additional dimension, and the output from this can be seen in figure 2.
A Three Dimensional Array
If a one dimensional array is analogous to a list, and a two dimensional array is analogous to a grid, then a three dimensional array is analogous to a cube (for example a Rubik's cube). The array elements are assigned in the same ways as with two dimensions (except, of course that there is an extra dimension):
And the 3 dimensional array can be used in a similar manner to 2 dimensions:
The result of using this code can be seen in figure 3.
Nth Dimensional Arrays
It is possible to have a maximum of 32 dimensions in a VBScript multidimensional array, but more than that will cause VBScript to run out of memory. However, since that's more than enough dimensions for a Quantum physicist then it's probably enough for the average VBScript programmer.