If IsNumeric(a) = False Then
MsgBox "数据非法"
Else
GetNumLen a,nInt,nDec
End if
Public Function GetNumLen(ByVal sgl As Single, ByRef nInt As Integer, ByRef nDec As Integer)
nInt = Len(CStr(Fix(sgl)))
If Len(CStr(sgl)) > nInt Then nDec = Len(CStr(sgl)) - nInt - 1
End Function
'sgl为小数,nInt为整数位数,nDec为小数位数
Public Function GetNumLen(ByVal sgl As Single, ByRef nInt As Integer, ByRef nDec As Integer)
nInt = Len(CStr(Fix(sgl)))
If Len(CStr(sgl)) > nInt Then nDec = Len(CStr(sgl)) - nInt - 1
End Function
private sub GetNumberLength(byval dblNum as double, byref l1 as integer, byref l2 as integer)
if instr(cstr(dblNum), ".")=0 then
l1=len(cstr(dblNum))
l2=0
else
l1=len(left(cstr(dblNum), instr(cstr(dblNum), ".")-1))
l2=len(mid(cstr(dblNum), instr(cstr(dblNum), ".")+1))
end if