在ASP编程中使用数组
程序员文章站
2022-04-14 20:27:13
数组的定义 dim myarray myarray = array(1,5,123,12,98) 可扩展数组 dim myarray...
数组的定义
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) & "<br>"
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) & "<br>"
next
在application和session中使用数组
application.lock
application("storedarray") = myarray
application.unlock
localarray = application("storedarray")
覆盖application中的数组
application.lock
application("storedarray") = localarray
application.unlock
session使用方法与application相同
从数据库中把数据导入数组中
dim myarray
取出全部记录
myarray = rs.getrows
取出前10项记录
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
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) & "<br>"
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) & "<br>"
next
在application和session中使用数组
application.lock
application("storedarray") = myarray
application.unlock
localarray = application("storedarray")
覆盖application中的数组
application.lock
application("storedarray") = localarray
application.unlock
session使用方法与application相同
从数据库中把数据导入数组中
dim myarray
取出全部记录
myarray = rs.getrows
取出前10项记录
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
上一篇: 模拟实现IoC容器
下一篇: 利用FSO取得图像文件信息