ASP字符串转换为整形、双精度型、布尔
更新时间:2008年05月15日 23:28:40 作者:
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
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中response.write(''中文'')或者js中文乱码问题
这篇文章主要介绍了asp中response.write('中文')或者js中文乱码问题,有时候我们需要输出js也会出现乱码,这里给出了几个解决方法,需要的朋友可以参考下2020-03-03
ASP中Server.Execute和Execute实现动态包含(include)脚本的区别
ASP中Server.Execute和Execute实现动态包含(include)脚本的区别,需要的朋友可以参考下。2012-01-01


最新评论