当前位置:主页 > 查看内容

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

发布时间:2021-07-02 00:00| 位朋友查看

简介:Rem将字符串转换为整形数据 functiontoInteger(str,num) str=trim(str) ifstr=""ornotisnumeric(str)then toInteger=num else toInteger=clng(str) endif endfunction Rem将字符串转换为双精度型数据 functiontoDouble(str) str=trim(str) ifstr=""ornotisnu……
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

原文链接:https://m.jb51.net/article/14447.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:ASP计算str2在str1中出现的次数 下一篇:没有了

推荐图文


随机推荐