如何在 CLASSIC ASP 中将字符串变量转换为 int,反之亦然

How to convert string variable to int and vice versa in CLASSIC ASP

我是经典的新手 asp。

    MaxLnkApp=rsTemp("Info")

    MaxLnkAppCount=rsTemp("Count")

    if MaxLnkApp=MaxLnkAppCount then
          averageNum = 0
    end if

rsTemp("Count") 是整数,rsTemp("Info") 是字符串

即使条件不满足(比如两个变量都等于 5)。

如何将字符串转换为整数?或整数到字符串?

问得好,在经典中ASP一切都是变体类型。

假设 rsTemp("Info") 和 rsTemp("Count") 都不能包含 NULL 值(从数据库返回),您可以使用 CStr(转换到字符串)

if CStr(MaxLnkApp) = CStr(MaxLnkAppCount) then

CLng(转换为长整型)

if CLng(MaxLnkApp) = CLng(MaxLnkAppCount) then
在这种情况下建议使用

CLng(而不是 CInt),因为 INT 的 SQL 服务器数据类型实际上是一个长整数。