Use arrays in ASP Programming
Array Definition
Dim myarray
Myarray = array (, 98)
Extensible Array
Dim myarray ()
For I = 0 to 10
Redim preserve myarray (I)
Myarray (I) = I
Next
An array that splits a string and returns the split result.
Dim myarray
Myarray = Split (tempcnt, CHR (13) & CHR (10 ))
For I = lbound (myarray) to ubound (myarray)
Response. Write myarray (I) & "<br>"
Next
Array sorting Function
Function .. sort (ary)
Keepchecking = true
Do until keepchecking = false
Keepchecking = false
For I = 0 to ubound (ary)
If I = ubound (ary) Then exit
If ary (I)> ary (I + 1) then
Firstvalue = ary (I)
Secondvalue = ary (I + 1)
Ary (I) = secondvalue
Ary (I + 1) = firstvalue
Keepchecking = true
End if
Next
Loop
Sort = ary
End function ..
Application Example of array sorting Function
Dim myarray
Myarray = array (, 98)
Myarray = sort (myarray)
For I = lbound (myarray) to ubound (myarray)
Response. Write myarray (I) & "<br>"
Next
Use arrays in application and session
Application. Lock
Application ("storedarray") = myarray
Application. Unlock
Localarray = Application ("storedarray ")
Overwrite the array in Application
Application. Lock
Application ("storedarray") = localarray
Application. Unlock
The session usage is the same as that of the application.
Import data from the database into the Array
Dim myarray
Retrieve all records
Myarray = Rs. getrows
Retrieve the first 10 records
Myarray = Rs. getrows (10)
For ROW = 0 to ubound (myarray, 2)
For Col = 0 to ubound (myarray, 1)
Response. Write (COL, row) & "<br>"
Next
Next