This is assuming you know the basic features of the array, so let's consider how to handle the ASP in VBScript.
The array in VBScript is 0, which means that the index of the group element always starts at 0. The array represented by the 0 exponent
The first position in the 1 exponent represents the second digit in the array, and so on.
There are two types of VBScript arrays-static and dynamic. The static array remains fixed in its entire life size. To
Using a static VBScript array you need to know the maximum number of previous elements this array will contain. If you
Need to index the size of the variable more flexible VBScript array, then you can use the dynamic VBScript array
。 The size of a dynamic array index in VBScript can increase/decrease in its lifetime.
Static array
Let's create an array of so-called ' arrcars ' that will hold the names of 5 cars
<%@ language= "VBSCRIPT"%>
<%
' Use the Dim statement along with the ' array name
' To create a static VBScript array
' The number in parentheses defines the array ' s upper bound
Dim Arrcars (4)
Arrcars (0) = "BMW"
Arrcars (1) = "Mercedes"
Arrcars (2) = "Audi"
Arrcars (3) = "Bentley"
Arrcars (4) = "Mini"
' Create a loop moving through the array
' and print out the values
For I=0 to 4
Response.Write Arrcars (i) & "<br>"
Next ' move on to ' next value of I
%>
Here's another way to define a VBScript array:
<%
' We use the VBScript Array function along with a Dim statement
' To create and populate our array
Dim Arrcars
Arrcars = Array ("BMW", "Mercedes", "Audi", "Bentley", "Mini") ' each element
Must be separated by a comma
' Again we could loop through the array and print out the values
For I=0 to 4
Response.Write Arrcars (i) & "<br>"
Next
%>
Dynamic array
The dynamic array comes in handy when you don't know how many items your array will hold. To create a dynamic array you should
The name of the array is used together the Dim statement does not specify an upper bound:
<%
Dim Arrcars
Arrcars = Array ()
%>
To use this array, you need to use the ReDim statement to define the upper bounds of the array:
<%
Dim Arrcars
Arrcars = Array ()
Redim Arrcars (27)
%>
If you need to adjust this array in the future, you should use the ReDim statement. Be very careful with ReDim statements.
When you use the ReDim statement you lose all of the array elements. The keywords saved with the ReDim statement will
Keep the array we've increased the size:
<%
Dim Arrcars
Arrcars = Array ()
Redim Arrcars (27)
Redim PRESERVE Arrcars (52)
%>