通过本文主要向大家介绍了js 字符串转布尔,字符串转布尔,字符串转布尔值,空字符串的布尔值,labview字符串转布尔等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
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
</div>
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
</div>