The elements in an array may not belong to the same data type. In ASP programming, a unified array name is usually used to determine the elements in an array. So do you know the method of using arrays in ASP programming? The new technology channel will explain it in detail today.
Definition of array
Dim MyArray
MyArray = Array(1,5,123,12,98)
Extended arrays
Dim MyArray()
for i = 0 to 10
ReDim Preserve MyArray(i)
MyArray(i)=i
next
Split a string and return an array of split results
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 For
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..
Example of array sorting function application
Dim MyArray
MyArray = Array(1,5,123,12,98)
MyArray = Sort(MyArray)
For I = Lbound(MyArray) to Ubound(MyArray)
Response.Write MyArray(I) & "<br>"
Next
Using arrays in Application and Session
Application.Lock
Application("StoredArray") = MyArray
Application.Unlock
LocalArray = Application("StoredArray")
Overwrite arrays in Application
Application.Lock
Application("StoredArray") = LocalArray
Application.Unlock
The Session is used the same as Application
Import data from the database into an array
Dim MyArray
Take out all records
MyArray = RS.GetRows
Take out 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
The method of using arrays in ASP programming, the editor of Foxin Technology Channel has introduced this to you. More knowledge is in Foxin Technology Channel. The editor hopes that everyone can learn useful knowledge in this article.