Using array _ Application techniques in ASP programming

Source: Internet
Author: User
Tags array sort chr
The definition of an array
Dim myarray
MyArray = Array (1,5,123,12,98)

Extensible array
Dim MyArray ()
For i = 0 to 10
ReDim Preserve myarray (i)
MyArray (i) =i
Next

Splits a string and returns an array of split results
Dim myarray
MyArray = Split (TEMPCNT,CHR) &CHR (10))
For I = Lbound (myarray) to Ubound (myarray)
Response.Write MyArray (I) & "<br>"
Next

Array sort 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 ...

An example of array sort 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 sessions
Application.Lock
Application ("StoredArray") = MyArray
Application.UnLock

LocalArray = Application ("StoredArray")

Overwrite an array in the application
Application.Lock
Application ("StoredArray") = LocalArray
Application.UnLock

Session using the same method as application

To import data into an array from a database
Dim myarray
Remove all records
MyArray = RS. GetRows
Take out the top 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

Related Article

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.