Reputation: 4521
We are playing around with EAN13-barcodes and checking if the number format is correct. And when it is we want to get the number out in the proper format. We get the compile error: "Expected: end of statement" when we try this. The error occurs in the "weight = first..." calculations in the code.
Any idea what might be wrong? Tried to google the error and we didn't find anything applicable to our situation.
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
Upvotes: 1
Views: 376
Reputation: 7352
Format for double literals in VB6 is 1.1
. You used a comma as fractional separation, and vb6 doesn't accept that.
Upvotes: 2
Reputation: 12799
You need to replace the commas with periods. Vb6 isn't recognizing then as decimal separators. 0,1
should be 0.1
etc
Upvotes: 2