Format(111,"###0.00")=111.00Format(1111111111111111111111111111111,"###0.00")=11111111111000000...超过30位,就不对了,怎么回事?      有什么办法?

解决方案 »

  1.   

    Dim i As Double
     i = CDbl(Format(1.11111111111111E+30, "###0.00"))
     Print i
      

  2.   

    Double精度不够,虽然数据可以达到10^308,但精度最大只有16位
      

  3.   

    Format(111,"###0.00")=111.00Format(1111111111111111111111111111111,"###0.00")=11111111111000000...VB的Format是通过数字方式处理的,你的数字太大,溢出了。自己做一个函数:Public Function FormatX(ByVal x As String) As String
    Dim p As Integer
    Dim i As Integer
    Dim strInt As String, strFra As String
    If InStr(x, "E") Then
        MsgBox "类型错误", vbCritical
        Exit Function
    End If
    If x Like "*[!0-9.]*" Then
        MsgBox "字符错误", vbCritical
        Exit Function
    End If
    p = InStr(x, ".")
    If p = 0 Then p = Len(x) + 1
    strInt = Left(x, p - 1)
    strFra = Mid(x, p + 1)
    For i = 1 To Len(strInt)
        If Mid(strInt, i, 1) <> "0" Then Exit For
    Next i
    strFra = Left(strFra, 2) & String(2 - Len(strFra), "0")
    FormatX = Mid(strInt, i) & "." & strFra
    End Function