紫影基地

 找回密码
 立即注册
查看: 173|回复: 0

[ASP] ASP教程:ASP关于数组的应用技巧

[复制链接]
阅读字号:

2006

主题

2121

帖子

21万

积分

超级版主

Rank: 8Rank: 8

积分
211127
发表于 2024-4-20 23:42:20 | 显示全部楼层 |阅读模式

数组的定义

Dim MyArray
MyArray = Array(1,5,123,12,98)

可扩展数组

Dim MyArray()
for i = 0 to 10
ReDim Preserve MyArray(i)
MyArray(i)=i
next

将一个字符串分割并返回分割结果的数组

Dim MyArray
MyArray = Split(tempcnt,chr(13)&chr(10))
For I = Lbound(MyArray) to Ubound(MyArray)
Response.Write MyArray(I) & "
"
Next

数组排序函数

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

数组排序函数应用例子

Dim MyArray
MyArray = Array(1,5,123,12,98)
MyArray = Sort(MyArray)
For I = Lbound(MyArray) to Ubound(MyArray)
Response.Write MyArray(I) & "
"
Next

在Application和Session中使用数组

Application.Lock
Application("StoredArray") = MyArray
Application.Unlock

LocalArray = Application("StoredArray")

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|紫影基地

GMT+8, 2025-1-26 11:32 , Processed in 0.082603 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表