我用串口接收数据是通过计算每位的数值然后相加为十进制的数时当数过大时会变成科学计数法表示如何变化为正常的十进制数

解决方案 »

  1.   

    Dim d As Double
        d = 1.23456789012346E+18
        
        Print Format(d, String(Len(d), "0"))
      

  2.   

    用四舍五入的函数:Round(Data,6)
      

  3.   

    这是原来在这里提问得到的答案
    dim Ca As Variant     
    Ca = CDec(0) '强制转换成Decimal 数据类型,对于没有小数点的数字,其范围是 +/-79,228,162,514,264,337,593,543,950,335
      

  4.   

    http://topic.csdn.net/u/20090105/11/7a9e2cd7-5365-4bb3-ac1d-7a8e630fc6c7.html
      

  5.   

    http://topic.csdn.net/u/20090105/11/7a9e2cd7-5365-4bb3-ac1d-7a8e630fc6c7.html
      

  6.   

    先排列成你要的16进制串 然后用:
    Function HEXTODEC(ByVal X As String) As String
    Dim a() As String, I As Long, UNIT As Integer
    For I = 1 To Len(X)
    If Not IsNumeric("&h" & Mid(X, I, 1)) Then MsgBox "NOT A HEX FORMAT!", 64, "INFO": Exit Function
    Next
    X = String((6 - Len(X) Mod 6) Mod 6, "0") & XUNIT = Len(X) \ 6 - 1
    ReDim a(UNIT)
    For I = 0 To UNIT
    a(I) = CLng("&h" & Mid(X, I * 6 + 1, 6))
    Next
    For I = 0 To UNIT
    a(I) = multi(a(I), POWERS(UNIT - I))
    HEXTODEC = sums(HEXTODEC, a(I))
    Next
    End FunctionFunction POWERS(ByVal X As Integer) As String ' GET 16777216^X,ie 16^(6*x)(16777216的X 次方)
    POWERS = 1
    Dim I As Integer
    For I = 1 To X
    POWERS = multi(POWERS, CLng(&H1000000))
    Next
    End Function
    Function multi(ByVal X As String, ByVal Y As String) As String 'multi of two huge hexnum(两个大数之积)
    Dim result As Variant
    Dim xl As Long, yl As Long, temp As Long, I As Long
    xl = Len(Trim(X))
    yl = Len(Trim(Y))ReDim result(1 To xl + yl)
    For I = 1 To xl
    For temp = 1 To yl
    result(I + temp) = result(I + temp) + Val(Mid(X, I, 1)) * Val(Mid(Y, temp, 1))
    Next
    NextFor I = xl + yl To 2 Step -1
    temp = result(I) \ 10
    result(I) = result(I) Mod 10
    result(I - 1) = result(I - 1) + temp
    NextIf result(1) = "0" Then result(1) = ""
    multi = Join(result, "")
    Erase resultEnd Function
    Function sums(ByVal X As String, ByVal Y As String) As String ' sum of two hugehexnum(两个大数之和)
    Dim max As Long, temp As Long, I As Long, result As Variant
    max = IIf(Len(X) >= Len(Y), Len(X), Len(Y))
    X = Right(String(max, "0") & X, max)
    Y = Right(String(max, "0") & Y, max)
    ReDim result(0 To max)
    For I = max To 1 Step -1
    result(I) = Val(Mid(X, I, 1)) + Val(Mid(Y, I, 1))
    Next
    For I = max To 1 Step -1
    temp = result(I) \ 10
    result(I) = result(I) Mod 10
    result(I - 1) = result(I - 1) + temp
    Next
    If result(0) = 0 Then result(0) = ""
    sums = Join(result, "")
    Erase resultEnd Function