当前位置: 代码迷 >> ASP >> 运行时提示下标越界解决方法
  详细解决方案

运行时提示下标越界解决方法

热度:395   发布时间:2012-02-29 16:44:10.0
运行时提示下标越界
function   FN_CalcScore(UID,GameID,AnswerStr)



dim   l,i,score,tmpscore,sumscore

l   =   0
i   =   0
score   =   0

if   left(GameID,1)   =   "Z "   then
l   =   5
tmpscore   =   1
end   if

if   left(GameID,1)   =   "Y "   then
l   =   10
tmpscore   =   3
end   if

if   left(GameID,1)   =   "J "   then
l   =   15
tmpscore   =   5
end   if

       
        a1   =   Split(trim(AnswerStr), "| ")
        a2   =   Split(trim(FN_GetCorrectAnswer(GameID)), "| ")
       
       
        for   i   =   0   to   l   -   1
        if   trim(a1(i))   =   trim(a2(i))   then
        score   =   score   +   1
        end   if
        next
       
        sumscore   =   score   +   tmpScore
       
        FN_SaveScore   UID,GameID,AnswerStr,l,score,l   -   score,tmpscore,sumscore
       
       
                                               
        end   function


这是什么原因啊

------解决方案--------------------
for i = 0 to l - 1
if trim(a1(i)) = trim(a2(i)) then
score = score + 1
end if
next
======================================
l=0不出错才怪呢?
应该是:
for i = 0 to ubound(a1) - 1
if trim(a1(i)) = trim(a2(i)) then
score = score + 1
end if
next
  相关解决方案