加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP字符串 转变为整形 双精度型 布尔

发布时间:2023-07-20 13:23:38 所属栏目:Asp教程 来源:
导读:Rem 将字符串转换为整形数据:function toInteger(str,num) str=trim(str) if str="" or not isnumeric(str) then toInteger=num else toInteger=clng(str)

Rem 将字符串转换为整形数据:

function toInteger(str,num)

        str=trim(str)

        if str="" or not isnumeric(str) then

              toInteger=num

        else

              toInteger=clng(str)

        end if

end function

Rem 将字符串转换为双精度型数据

function toDouble(str)

       str=trim(str)

       if str="" or not isnumeric(str) then

              toDouble=0.0

      else

              toDouble=cdbl(str)

      end if

end function

Rem 将字符串转换为布尔数据

function toBoolean(str)

      str=lcase(trim(str))

      if str="true" or str="t" then

            toBoolean=true

     elseif isnumeric(str) then

            if clng(str)<>0 then toBoolean=true

     else

           toBoolean=false

    end if

end function

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章