有人可以告訴我爲什麼這是折騰類型不匹配使用傳統的ASP錯誤?經典的ASP類型不匹配,如果然後語句
If (strPaidByPO = True) OR (arrResult(0) = "1") Then
'Do Stuff
Else
'Do Other stuff
End if
arrResults是一個數組,strPaidByPO是一個變量。
感謝,
有人可以告訴我爲什麼這是折騰類型不匹配使用傳統的ASP錯誤?經典的ASP類型不匹配,如果然後語句
If (strPaidByPO = True) OR (arrResult(0) = "1") Then
'Do Stuff
Else
'Do Other stuff
End if
arrResults是一個數組,strPaidByPO是一個變量。
感謝,
的If
聲明之前鍵入以下內容(我想你可以圍繞類型來作出的假設)。
Call Response.Write(TypeName(strPaidByPO) & "<br />")
Call Response.Write(TypeName(arrResult) & "<br />")
Call Response.Flush()
如果你的變量是你的預期,你應該得到下面的輸出
Boolean
Variant()
你也可能,如果你的陣列是在你需要指定所有維這種情況下,多維收到這類型的。
另一種可能性是arrResult(0)
包含除String
以外的內容。在這種情況下,使用TypeName(arrResult(0))
來檢查是什麼。
試試這個,看看結果在此基礎上,你可以糾正你的腳本:
response.write(cStr(strPaidByPO) & "- My strPaidByPO value<br>")
response.write(arrResult(0) & "- My Array value")
If (strPaidByPO = True) OR (cStr(arrResult(0)) = "1") Then
'Do Stuff
Else
'Do Other stuff
End if
但如果你strPaidByPO包含其他值,那麼真 - 假(布爾),你需要徹底檢討你的方法了這一點。例如,如果strPaidByPO爲NULL或爲空,您的腳本將會通過您所描述的錯誤。