好的我是一個完全新手到ASP。控制經典ASP中的空陣列
我有取決於什麼是在陣列通過不同的內容加載客戶端。
select case lcase(arURL(4))
雖然有時,arURL(4)
可能是空的,在他們的情況下,我發現了以下錯誤:
錯誤運行功能functionName()
,錯誤是:
Subscript out of range
有誰知道解決這個問題的方法?
謝謝
確定進一步的代碼按要求。這是可怕的代碼,我不想讓任何人頭痛,所以請原諒。再次感謝........
function GetContent()
dim strURL, arURL, strRetval
select case lcase(request.ServerVariables("URL"))
case "/content.asp"
strURL = ""
arURL = split(request.querystring("url"), "/")
if request("page") = "" then
select case lcase(arURL(2))
case "searches"
select case lcase(arURL(1))
case "looking"
select case lcase(arURL(3))
case "ohai"
strRetval = "Lorem"
case "blahblah"
strRetval = "Lorem Ipsum"
case "edinburgh"
select case lcase(arURL(4))
case "ohai"
strRetval = "Ipsum"
case "ohno"
strRetval = "Lorem"
end select
case "bristol"
select case lcase(arURL(4))
case "some_blahblah"
strRetval = "LOREM"
case "overthere"
strRetval = "LOREM"
case "blahblah"
strRetval = "LOREM"
end select
case "cambridge"
select case lcase(arURL(4))
case "some_rubbish"
strRetval = "Lorem"
end select
case else
strRetval = " "
end select
case else
strRetval = " "
end select
case else
strRetval = " "
end select
end if
end select
strRetval = strRetval & "<style>h2{border: 0px);</style>"
GetContent = strRetval
end function
首先你需要知道數組的上限,比如ubound(arURL)。當您嘗試訪問不在您的陣列中的索引時顯示此錯誤 – polin