如何阻止小數在Visual Basic中被截斷,並以科學記數法將其保留爲完整小數而不是截斷數字?在Visual Basic中停止十進制截斷
我有從我修改有人上午Excel宏代碼這一點(只有Debug.Print語句是我的):
rttime = asht.Cells(i, timecol).Value
Debug.Print "rttime=" & rttime
Debug.Print "To string: " & CStr(CDec(rttime))
rtdelta = rttime - wavonset_value 'searchcol="AOISlide2"
Debug.Print "rtdelta=" & rtdelta
的Debug.Print語句給我:
rttime=1.343301E+12
To string: 1343301000000
rtdelta=0
因此,基本上這裏發生的是以科學記數法從Excel工作表中拉出的值,並且在該表示法中未顯示的所有內容都被截斷。
的實際數量應該是1343300687515.39,但它正在下被迫1.343301E + 12,即使我逼出來的科學記數法的,它仍然給我13433.01億。
我怎樣才能得到它與小數點和所有的實際數字?這方面實際上是需要的,因爲在某些情況下,可能只有20個左右的差異,但是由於它被截斷到數百萬個地方,所以它是完全沒有用的。
編輯:下面是引用
Function GetAOIRowStart(asht As Worksheet, startrow&, endrow&, searchstr$, searchcol&,
AOItime_start As Single) As Long
Dim i&
Dim rtdelta As Single
Dim rttime As Single
Dim wavonset_value As Single
Dim timecol&
timecol = 4
wavonset_value = asht.Cells(startrow, timecol).Value 'tettime
Debug.Print "wavonset_value=" & wavonset_value
i = startrow
Do Until i >= endrow
'scan down TeTTime' column to find nearest look of interest
rttime = asht.Cells(i, timecol).Value
Debug.Print "rttime=" & rttime
Debug.Print "To string: " & CStr(CDec(rttime))
rtdelta = CDec(Right(rttime, 9)) - CDec(Right(wavonset_value, 9)) 'searchcol="AOISlide2"
Debug.Print "rtdelta=" & rtdelta
If rtdelta >= AOItime_start Then
Exit Do
End If
i = i + 1
Loop
GetAOIRowStart = i
'Debug.Print asht.Cells(i, sound_playing_col).Value
End Function
我認爲它與Excel的數值精度有關(順便說一下,這不是很好)...... Excel中非常大(或非常小)的數字被截斷 – Barranka 2013-05-07 23:27:55
@Barranka我實際上已經設置了電子表格集不截斷數字。在電子表格中,它顯示了整個數字,小數點和全部。 – 2013-05-07 23:34:13
這是'rttime'的類型? (我試圖重現這種情況) – Barranka 2013-05-07 23:38:41