asp运行老是报错,下标越界: 'i' ,(在线等)

sarm 2003-08-28 11:17:40
小弟是改别人的代码调试:
原始代码是:
randomize
for i=0 to 9
q=0
x(i)=fix((20-1+1)*rnd+1)
if i=0 then
else
do until q=1
for y=0 to (i-1)
if x(i)=x(y) then
x(i)=fix((20-1+1)*rnd+1)
y=-1
end if
q=1
next
loop
end if
next
for i= 0to 9
'response.write x(i)&","
next

for i=0 to 9

c="select * from test where ID="&x(i)
set rs=conn.execute(c)
我改动以后的代码如下:
randomize
for i=0 to 39
q=0
x(i)=fix((75-1+1)*rnd+1)
if i=0 then
else
do until q=1
for y=0 to (i-1)
if x(i)=x(y) then
x(i)=fix((75-1+1)*rnd+1) 这个就是118行!
y=-1
end if
q=1
next
loop
end if
next
for i= 0 to 39
'response.write x(i)&","
next

for i=0 to 39

c="select * from test where ID="&x(i)
set rs=conn.execute(c)

报错信息是:
Microsoft VBScript 运行时错误 错误 '800a0009'

下标越界: 'i'

/wsdt/ks/test.asp,行118
...全文
52 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
DerryZhang 2003-08-28
  • 打赏
  • 举报
回复
up up
Reker熊 2003-08-28
  • 打赏
  • 举报
回复
<%
Dim x(40)
Randomize
For i=0 To 39
q=0
x(i)=Fix((75-1+1)*Rnd+1)
If i<>0 Then
Do Until q=1
For y=0 To (i-1)
If x(i)=x(y) Then
x(i)=Fix((75-1+1)*Rnd+1)
Exit For
End If
q=1
Next
Loop
End if
Next

For I=0 To 39
Response.Write x(i)&","
Next
%>
sarm 2003-08-28
  • 打赏
  • 举报
回复
太感谢了,特别要谢谢 wolf004(色胚) 兄!
61 2003-08-28
  • 打赏
  • 举报
回复
你定义数组的代码在那?请贴全代码!
或检查定义数组语句
wolf004 2003-08-28
  • 打赏
  • 举报
回复
for i=0 to 39

c="select * from test where ID="&x(i)
set rs=conn.execute(c)

39??
x(39)你定义了吗?
你要定义
dim x(40)
wolf004 2003-08-28
  • 打赏
  • 举报
回复
dim x(10)
Brookes 2003-08-28
  • 打赏
  • 举报
回复
检查一下x数组的定义。
Brookes 2003-08-28
  • 打赏
  • 举报
回复
检查一下x的数组声明,如
dim x(38)
Primer2002cn 2003-08-28
  • 打赏
  • 举报
回复
逻辑是什么?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧