數(shù)組中的元素可能不屬于同一數(shù)據(jù)類型,在ASP編程中通常都是使用統(tǒng)一的數(shù)組名稱和來確定數(shù)組中的元素,那么在ASP編程中使用數(shù)組的方法大家都知道嗎?錯(cuò)新技術(shù)頻道今天就為你詳細(xì)講解。
數(shù)組的定義
Dim?MyArray
MyArray?=?Array(1,5,123,12,98)
可擴(kuò)展數(shù)組
Dim?MyArray()
for?i?=?0?to?10
ReDim?Preserve?MyArray(i)
MyArray(i)=i
next
將一個(gè)字符串分割并返回分割結(jié)果的數(shù)組
Dim?MyArray
MyArray?=?Split(tempcnt,chr(13)&chr(10))
For?I?=?Lbound(MyArray)?to?Ubound(MyArray)?
Response.Write?MyArray(I)?&?"<br>"
Next?
數(shù)組排序函數(shù)
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..
數(shù)組排序函數(shù)應(yīng)用例子
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?
在Application和Session中使用數(shù)組
Application.Lock
Application("StoredArray")?=?MyArray
Application.Unlock
LocalArray?=?Application("StoredArray")
覆蓋Application中的數(shù)組
Application.Lock
Application("StoredArray")?=?LocalArray
Application.Unlock
Session使用方法與Application相同
從數(shù)據(jù)庫中把數(shù)據(jù)導(dǎo)入數(shù)組中
Dim?MyArray
取出全部記錄
MyArray?=?RS.GetRows
取出前10項(xiàng)記錄
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
在ASP編程中使用數(shù)組的方法,錯(cuò)新技術(shù)頻道小編就為大家介紹到這里了,更多的知識(shí)盡在錯(cuò)新技術(shù)頻道,小編希望大家能在本文中學(xué)習(xí)到有用的知識(shí)。
新聞熱點(diǎn)
疑難解答
圖片精選