日期:2014-05-17  浏览次数:21277 次

谢谢(hookee)兄,这代码我运行没问题,但我结合到排序函数中就没成功.帮我看下,谢谢
这段是数组排序代码
<%
dim   arr(3,3),temp(2)
dim   i,temp0,col
arr(0,0)   =   "0023 "
arr(0,1)   =   "元素2 "
arr(0,2)   =   "1.34 "

arr(1,0)   =   "0003 "
arr(1,1)   =   "元素5 "
arr(1,2)   =   "1.05 "

arr(2,0)   =   "0014 "
arr(2,1)   =   "元素1 "
arr(2,2)   =   "0.02 "

function   test(col)
        for   i   =   0   to   2   '数组上限
            if   arr(i,col)   <   arr(i+1,col)   then
                temp(0)   =   arr(i+1,0)
                arr(i+1,0)   =   arr(i,0)
                arr(i,0)   =   temp(0)

                temp(1)   =   arr(i+1,1)
                arr(i+1,1)   =   arr(i,1)
                arr(i,1)   =   temp(1)

                temp(2)   =   arr(i+1,2)
                arr(i+1,2)   =   arr(i,2)
                arr(i,2)   =   temp(2)
            end   if
        next
        test   =   arr
end   function

call   test(0)

response.write   " <table   border= '1 '> "
for   x   =   0   to   2
response.write   " <tr> "
    for   y   =   0   to   2
        response.write   " <td> "&arr(x,y)& " </td> "
    next

next
response.write   " </table> "

%>

------解决方案--------------------
<%
BL = "0023,元素2,1.34-0003,元素5,1.05-0014,元素1,0.02 "
b = split(BL, "- ") ' 行数上限
c = split(b(0), ", ") ' 元素上限
Dim all()
ReDim all(UBound(b),UBound(c)) '建立数组

For p=0 To UBound(b) '循环行数
d = split(b(p), ", ") '获得没行元素
For j=0 To UBound(c) '元素上限循环
all(p,j) = d(j) '给A数组赋值
Next
Next

Set rs = CreateObject( "ADODB.RecordSet ")
rs.cursorLocation=3
rs.Fields.Append "num ", 200, 50
rs.Fields.Append "name ", 200, 50
rs.Fields.Append "price ", 6, 8
rs.open
For p=0 To UBound(all,2)
rs.Addnew
rs( "num ")=all(p,0)
rs( "name ")=all(p,1)
rs( "price ")=all(p,2)
Next
rs.sort = "num ASC " '根据num排序
rs.movefirst

response.write " <table border= '1 '> "
Do While Not rs.eof
response.write " <tr> "
response.write " <td> "& rs( "num ") & " </td> "
response.write " <td> &qu