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