vb 中如何判断小数点的位数

来源:百度知道 编辑:UC知道 时间:2024/05/12 17:57:15
比如2.365得出3

s = "3.356"
print "小数点后有" & len(s) - instr(s,".") & "位"

private function GetDigitCount(anyNumber as double) as integer
GetDigitCount=0
dim strNumber as string
strNumber=cstr(anyNumber)

dim a
on error resume next
a=split(strNumber,".")
GetDigitCount=len(a(1))
end function

CInt(2.365)返回2
Round(2.365)返回2
Format(2.365,"0")返回2