【发布时间】:2014-04-24 06:42:35
【问题描述】:
谁能告诉我为什么这是使用经典 ASP 错误抛出类型不匹配?
If (strPaidByPO = True) OR (arrResult(0) = "1") Then
'Do Stuff
Else
'Do Other stuff
End if
arrResults 是一个数组,strPaidByPO 是一个变量。
谢谢,
【问题讨论】:
标签: vbscript asp-classic
谁能告诉我为什么这是使用经典 ASP 错误抛出类型不匹配?
If (strPaidByPO = True) OR (arrResult(0) = "1") Then
'Do Stuff
Else
'Do Other stuff
End if
arrResults 是一个数组,strPaidByPO 是一个变量。
谢谢,
【问题讨论】:
标签: vbscript asp-classic
在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 包含除 true - false (布尔值)以外的值,您需要完全检查您的方法。例如,如果 strPaidByPO 为 NULL 或为空,您的脚本将向您发送您描述的错误。
【讨论】: