我們在玩弄EAN13條形碼並檢查數字格式是否正確。如果是這樣,我們希望以適當的格式獲取數字。我們得到編譯錯誤:「預期:語句結束」當我們嘗試這個。 錯誤發生在代碼中的「weight = first ...」計算中。如何在Visual Basic 6中倍增倍數?
任何想法可能是錯誤的?試圖谷歌錯誤,我們沒有發現任何適用於我們的情況。
Dim first As Double
Dim second As Double
Dim third As Double
Dim fourth As Double
If Left(data, 5) = 3 Or Left(data, 5) = 4 Or Left(data, 5) = 5 Then
' Checking if it's a weight and then converting the string to double
first = CDbl(Val(Left(data, 12)))
second = CDbl(Val(Left(data, 13)))
third = CDbl(Val(Left(data, 14)))
fourth = CDbl(Val(Left(data, 15)))
If Left(data, 5) = 3 Then
' 1,234 kg
weight = first * 1 + second * 0,1 + third * 0,01 + fourth * 0,001
ElseIf Left(data, 5) = 4 Then
' 12,34 kg
weight = first * 10 + second * 1 + third * 0,1 + fourth * 0,01
ElseIf Left(data, 5) = 5 Then
' 123,4 kg
weight = first * 100 + second * 10 + third * 1 + fourth * 0,1
End If
End If
End If
嘗試用小數值中的''替換''' – pinkfloydx33
@ pinkfloydx33噢,上帝......爲什麼我們沒有想到這個? – Danieboy