问题描述:
高手们,帮帮忙看一下啦!!
Microsoft VBScript 运行时错误 错误 '800a0009'
下标越界: 'i'
Cart_List文件部分代码如下
<%
url=request.servervariables("_referer")
ProdIds = Session("ProdIds")
ProdNums = Session("ProdNums")
call up("购物车状态","购物车状态","购物车状态")
response.write "<tr>"
response.write " <td>"
response.write " <table border=1 width=100% cellpadding=4 style='border-collapse: collapse' bordercolor=#DFDFDF>"
response.write "<tr bgcolor=#f2f2f2><td>商品名称</td><td>市场价</td><td>网站价</td><td>订购数量</td><td>小计</td><td>删除</td></tr>"
response.write "<form action=Cart_List method=post name=form1 onsubmit=return CheckFrom()>"
response.write "<input type=hidden name=cmdShow value=Yes>"
if ProdIds<>"" then
aaa=split(ProdNums,",")
bbb=split(ProdIds,",")
pbuynums=Request("pbuynums")
Quatitys=split(Request("pbuynums"),",")
session("y")=ubound(bbb)+1
for i=0 to ubound(bbb)
set rs=server.createobject("adodb.recordset")
sql="select id,product_info_PriceM,product_info_PriceS,Shop_name from product where id="&bbb(i)
rs.open sql,conn,1,1
if rs.eof or rs.bof then
response.write "<tr><td colspan=6 align=center><a href='javascript:history.go(-1)'><<购物车为空,请返回选购商品</a></td></tr>"
else
set id=rs(0)
set product_info_PriceM=rs(1)
set RMB=rs(2)
set product_info_name=rs(3)
While Not rs.EOF
Quatity = Quatitys(i)
If Quatity <>"" Then
x=Quatity
else
x=aaa(i)
if aaa(i)="" then x=1
end if
sum1=sum1 + csng(rmb) * x
sum=FormatNumber(sum1,2,-1)
session("sum")=sum
response.write "<tr>"
response.write " <td><input type=hidden name=mc value="&id&"><a href=Product_Detail?id="&id&" target=_blank>"&Shop_name&"</a></td>"
response.write " <td>¥"&FormatNumber(product_info_PriceM,2,-1)&"</td>"
response.write " <td><font color=#FF0000>¥"&FormatNumber(Rmb,2,-1)&"</font></td>"
response.write " <td><input name=pbuynums value="&x&" size=5 maxlength=5></td>"
response.write " <td>¥"&FormatNumber((csng(rmb)*x),2,-1)&"</td>"
response.write " <td><a href=Cart_Del?MyAction=Del&id="&id&">删除</a></td>"
response.write "</tr>"
rs.MoveNext
Wend
end if
rs.close
set rs=nothing
next
%>
解析:
有问题的部分:
aaa=split(ProdNums,",")
bbb=split(ProdIds,",")
问题:你能保证 aaa、bbb 通过 Split 函数分割出来的数组下标完全一致?若不一致因该在调用前检查一下,问题就出现在这里。
调试:
Response.Write aaa &"<br>" &bbb
Response.End
这样输出一下 aaa、bbb 值看看是否正确。
修改:
你没给出发生错误的位置,我根据代码推断因该是以下代码发生错误:
x=aaa(i)
if aaa(i)="" then x=1
这段代码改为
If i >UBound(aaa) Then
x = 1
ElseIf aaa(i) = "" Then
x = 1
Else
x = aaa(i)
End If
pii超过了ttp这个数组的最大索引值,就会提示“下标越界”。至于为什么会超过,仅从你这些代码是看不出的。你应该先判断pii是否超出数组上限再来做下一步动作:比如把第135行改为如下:
<td width="160" rowspan="9" align="center" ><%if pii<=ubound(ttp) then response.write ttp(pii)%></td>
A woman is a mysteryA man just cant understand
女人是个男人不懂的谜
Sometimes all it takes to please her
Is the touch of your hand
有时候仅仅是你的抚摸就可以令她欢快
N' Other times you got to take it slow
有时候却得慢慢忍耐
And hold her all night long
甚至一夜不眠的抚慰她
Heaven knows there's so many ways
A man can go wrong
天知道男人有太多种犯错的方式
Chorus
(合唱)
Must be doin' somethin' right
得做一些正确的事了
I just heard ya sigh
我已经听见了你的叹息
N' Lean into my kiss
现在沉浸于我的吻中
And close those deep blue need to eyes
然后闭上你那双深蓝的眼睛
Don't know what I did
To earn a love like thi
我不知道如何得到一份这样的爱
But baby I must be doin' somethin' right
oh~亲爱的~我必须要做一些正确的事
Anywhere you wanna go
你想去的任何地方
Baby show me the way
亲爱的 请告诉我方向
I'm open to suggestions
Mmm whatever you say
我已经准备好接受你提出的任何建议
Tonight's about givin' you what you want
Whatever it takes
今夜我要给你你想要的 无论代价
Girl I hope i'm on the right road
女孩 但愿我在正确的路上
Judgin by the smile on your face
通过你脸上的微笑来确定
欢迎分享,转载请注明来源:优选云