function checkip(ip) '检测指定IP是否投过票
dim ipArray()
sql="Select ip from Candidate where id="&id
Set rs2=cnn.execute(sql)
ipArray()=split(rs2,",")出错行
For i = 0 To UBound(ipArray)
if ip=ipArray(i) then
checkip=true
else
checkip=false
end if
next
end function
错误提示如下:
# 错误类型:
Microsoft VBScript 运行时错误 (0x800A000D)
类型不匹配
程序代码:
function checkip(ip) '检测指定IP是否投过票
dim ipArray()
sql="Select ip from Candidate where id="&id
Set rs2=cnn.execute(sql)
ipArray()=split(rs2(0),",")出错行
For i = 0 To UBound(ipArray)
if ip=ipArray(i) then
checkip=true
else
checkip=false
end if
next
end function
直接定义数组名就可以了,如果要重新定义可用NEW
function checkip(ip) '检测指定IP是否投过票
dim ipArray
sql="Select ip from Candidate where id="&id
Set rs2=cnn.execute(sql)
ipArray=sp ...
我昨天测试数组:
dim arr1()
arr1(0)=1
arr1(1)=2
结果输出错误:下标出界
dim arr1(5)
arr1(0)=1
arr1(1)=2
错误同样是下标出界
应该就是你说的这个问题吧,应该直接定义?
直接定义数组名就可以了,如果要重新定义可用NEW
function checkip(ip) '检测指定IP是否投过票
dim ipArray
sql="Select ip from Candidate where id="&id
Set rs2=cnn.execute(sql)
ipArray=split(rs2("ip"),",")
ipArray=New ipArray()
For i = 0 To UBound(ipArray)
if ip=ipArray(i) then
checkip=true
else
checkip=false
end if
next
end function