ASP字符串轉(zhuǎn)換為整形、雙精度型、布爾
更新時間:2008年05月15日 23:28:40 作者:
asp可以輕松將字符串類型轉(zhuǎn)化為其它類型的函數(shù)
Rem 將字符串轉(zhuǎn)換為整形數(shù)據(jù)
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 將字符串轉(zhuǎn)換為雙精度型數(shù)據(jù)
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 將字符串轉(zhuǎn)換為布爾數(shù)據(jù)
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 將字符串轉(zhuǎn)換為雙精度型數(shù)據(jù)
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 將字符串轉(zhuǎn)換為布爾數(shù)據(jù)
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
相關(guān)文章
談動態(tài)多行多列,循環(huán)行和列,輸出M行N列的ASP代碼
2008-03-03ASP中怎么實現(xiàn)SQL數(shù)據(jù)庫備份、恢復(fù)!
ASP中怎么實現(xiàn)SQL數(shù)據(jù)庫備份、恢復(fù)!...2007-03-03DefiniteUrl asp將相對地址轉(zhuǎn)換為絕對地址的代碼
DefiniteUrl asp將相對地址轉(zhuǎn)換為絕對地址的代碼...2007-09-09ASP 下載時重命名已上傳文件的新下載文件名的實現(xiàn)代碼
標(biāo)題有點(diǎn)拗口,今天群里在說這個問題,CSDN有答案,附上,需要的朋友可以參考下2012-03-03