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

2017 年 11 月 29 日2490

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

作者: 字体:[ ] 类型:转载 时间:2008-05-15

asp可以轻松将字符串类型转化为其它类型的函数

Rem将字符串转换为整形数据
functiontoInteger(str,num)
str=trim(str)
ifstr=""ornotisnumeric(str)then
toInteger=num
else
toInteger=clng(str)
endif
endfunction

Rem将字符串转换为双精度型数据
functiontoDouble(str)
str=trim(str)
ifstr=""ornotisnumeric(str)then
toDouble=0.0
else
toDouble=cdbl(str)
endif
endfunction

Rem将字符串转换为布尔数据
functiontoBoolean(str)
str=lcase(trim(str))
ifstr="true"orstr="t"then
toBoolean=true
elseifisnumeric(str)then
ifclng(str)<>0thentoBoolean=true
else
toBoolean=false
endif
endfunction

Tags:

相关文章

最新评论

大家感兴趣的内容

最近更新的内容

常用在线小工具

0 0