分享

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

 丑的不明显 2010-10-28
ASP字符串转换为整形、双精度型、布尔
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 
ASP字符串转换为整形、双精度型、布尔


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多