Working With Arrays |
Top Previous Next |
For further information see: http://www.winguides.com/scripting Arrays are used to group and store a set of variables together in one object. VBScript supports both simple and multi-dimensional arrays with up to 60 dimensions. Defining Arrays Dim MyArray(4) Since all arrays start with the index number zero it is counted as the first number, there this array very though it was defined as MyArray(4) contains five elements: 0, 1, 2, 3, 4. Using Arrays MyArray(0) = "First element" MyArray(1) = "Second Element" Then to retrieve and echo the data you could use: SMEvent.Raise "Trace", MyArray(1) Multi-Dimensional Arrays Dim MultiArray(4,5) Sizing Arrays For example, in a function where the size of the array will be based on the number of variables, you could use the following command to resize it: ReDim Preserve MyArray(count - 1) Note: Use the Preserve keyword to prevent the contents of the array being lost when using the ReDim function. |