错误检查在VBScript NULL [英] Error checking for NULL in VBScript
问题描述
我有下面的VBScript中传统的ASP页:
I have the following VBScript in a Classic ASP page:
function getMagicLink(fromWhere, provider)
dim url
url = "magic.asp?fromwhere=" & fromWhere
If Not provider is Nothing Then ' Error occurs here
url = url & "&provider=" & provider
End if
getMagicLink = "<a target='_blank' href='" & url & "'>" & number & "</a>"
end function
我不断收到关于这行对象需要错误信使如果没有供应商是没有那么
。
要么值为NULL,或者它不为空,所以为什么我收到此错误?
Either the value is NULL, or it's not NULL, so why am I getting this error?
编辑:如果我调用对象,我通过在为NULL,或者我传递一个字符串
When I invoke the object, I pass in either NULL, or I pass in a string.
推荐答案
从code,它看起来像提供商
是一个变体或其他一些变量,不是对象。
From your code, it looks like provider
is a variant or some other variable, and not an object.
是Nothing
是唯一的对象,但后来你说这是一个值,要么是NULL或NOT NULL,将由处理ISNULL
。
Is Nothing
is for objects only, yet later you say it's a value that should either be NULL or NOT NULL, which would be handled by IsNull
.
请尝试使用:
If Not IsNull(provider) Then
url = url & "&provider=" & provider
End if
另外,如果还是不行,请尝试:
Alternately, if that doesn't work, try:
If provider <> "" Then
url = url & "&provider=" & provider
End if
这篇关于错误检查在VBScript NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!