ASP字符串转换为整形、双精度型、布尔
发布时间:2016-12-29 来源:查字典编辑
摘要:Rem将字符串转换为整形数据functiontoInteger(str,num)str=trim(str)ifstr=""ornotisnu...
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