何かが足りない。:-)
次のバーコードではなく、最後のバーコードの値を保存する必要があります。新しいものが前回と同じ場合は、数量を増やします。同じでない場合は、数量を 1 にリセットし、新しいバーコードを最後のバーコードとして保存します。
Dim lastItemBarcode As String = ""
Dim quantity As Integer
' Scan now. If this is the first bar code,
' quantity will be set to 1 in the Else branch below
' Your scan should work in a loop starting here, so
' it keeps going and doesn't reset lastItemBarcode
' or quantity
If Me.txtBarkodi.Text = lastItemBarcode Then
' bar code same as last. Just increase quantity
quantity += 1
Else
' Either the first item scanned, or a different
' item. Save this bar code as the current one,
' and start our queantity at 1
lastItemBarcode = me.txtBarkodi.Text
quantity = 1
End If