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

编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
asp可以轻松将字符串类型转化为其它类型的函数
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

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板