服务器之家

服务器之家 > 正文

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

时间:2019-09-27 09:15     来源/作者: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 

相关文章

热门资讯

玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
华为nova5pro和p30pro哪个好 华为nova5pro和华为p30pro对比详情
华为nova5pro和p30pro哪个好 华为nova5pro和华为p30pro对比详情 2019-06-22
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
抖音撒撒累累是什么歌 撒撒累累张艺兴歌曲名字
抖音撒撒累累是什么歌 撒撒累累张艺兴歌曲名字 2019-06-05
超A是什么意思 你好a表达的是什么
超A是什么意思 你好a表达的是什么 2019-06-06
返回顶部