如何将类似 ".5"数值改为"0.5"显示
Private Function f(str As String) As StringIf IsNumeric(str) Then
If Val(str)0 Then f = "0" & Trim(str) Else f = Trim(str)
Else
f = str
End If
End Function
我曾经这样写上面的函数:
Private Function f(str As String) As String
If Left(str,1)="." And IsNumeric(str) Then f="0" & str Else f=str
End Function 在VB中可直接用Format函数。
如:保存小数点后两位,可以用Format(1.23456,".00")=1.23,
如果点号之前补零的话,只要Format(0.23456,"0.00")=0.23。 你的方法太复杂,将数字转换成字符串时用函数"format(aaa,"0.00")"即可 使用format加以格式话
页:
[1]