The standard vbscript array is created as so…
Dim degrees(4)
degrees(0) = “Associate in Applied Science Transfer”
degrees(1) = “Associate in Arts, University and College Transfer”
degrees(2) = “Associate in Arts, General Studies”
degrees(3) = “Associate in Science”
degrees(4) = “Associate in Technical Arts”
These arrays are not dynamic and need some work to add data to them. You can also create arrays by splitting strings as seen in my post about asp string manipulation techniques.
count = 23 ‘ set from database pull
Dim myarray()
ReDim Preserve myarray(count)
For x = 1 to count
myarray(x) = mydynamicitemhere
Next
Dump the contents of an array to the screen for debug:
For Each item In myFixedArray Response.Write(item & "<br />") Next
A two dimensional array would be achieved as so…
Dim listofslides()
ReDim preserve listofslides(4,4) ‘ sequence, filename, description, enabled
listofslides(0,0)=1
listofslides(0,1)=”image1.jpg”
listofslides(0,2)=”Description of image 1″
listofslides(0,3)=1
But if you are getting the array from an information storage system, then its super easy.
sub grabdata
SQL_query = "SELECT * FROM MSAccess_table"
Set rsData = conn.Execute(SQL_query)
If Not rsData.EOF Then aData = rsData.GetRows()
end sub
and you use the array like this
If IsArray(aData) Then
For x = lBound(aData,2) to uBound(aData,2) 'loops through the rows
Col1 = aData(0,x)
Col2 = aData(1,x)
Col3 = aData(2,x)
Response.Write "Row #" & x+1 & "
"
Response.Write "This is the data in Column1: " & Col1 & "
"
Response.Write "This is the data in Column2: " & Col2 & "
"
Response.Write "This is the data in Column3: " & Col3 & "
"
Next
End If