当前位置: 移动技术网 > IT编程>开发语言>Asp > ASP字符串转换为整形、双精度型、布尔

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网