ASP Len()函数返回Type Mismatch错误

时间:2017-04-25 01:36:48

标签: vbscript asp-classic

下面是我的经典ASP应用程序的服务器端asp代码:

Function isValidPACSSession()
...
Dim sessionID : sessionID = Request.QueryString("forSessionID")
isValidPACSSession = SessionID2PACSUserID(sessionID)
...
End Function

Function SessionID2PACSUserID(sSessionID)
if (Not IsNull(sSessionID) AND Len(sSessionID) > 0) then
            ...it fails here at the Len function.
        else
            ...
        end if
End Function

Len()函数会抛出此类型实例的“类型不匹配”错误,而其他组件对SessionID2PACSUserID()的其他调用也很好。请帮忙。

2 个答案:

答案 0 :(得分:0)

看起来你只是想检查一个值是否存在,为什么不这样做:

dim sessionLength : sessionLength = 0
if (Not IsNull(sSessionID) AND sSessionID <> "") then
    sessionLength = Len( sSessionID )

我也同意VS调试器的上述声明与经典的asp

不能很好地协同工作

答案 1 :(得分:0)

找到了一个解决方案..实际上我在calle网页上有一个名为“len”的局部变量,导致len()失败。将len变量名称更改为nLength,Len()现在可以正常工作。