ASP array usage

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.