I have an app using A5V8 and I need to add a check digit to a UPC barcode values where that check digit had been removed by someone else.
I assume this would be done via an update. If I'm wrong let me know.
I have some instructions and sample code (unfortunately it's in Visual Basic)
How would I make it go? see instructions and sample code below
Thanks in advance.
UPC barcodes include a check digit. The UPC check digit is the 12th digit in the lower-right corner of the barcode. Here's how to calculate a UPC barcode check digit
The last digit in a UPC barcode is a check digit based on the previous 11 numbers. Our example barcode data is "41234554321"
Add up the numbers in the odd positions left to right. Multiple the result by 3. Add up the numbers in the even positions. Now add the first subtotal to the second. The UPC barcode check digit is the single digit number makes the total a multiple of 10.
4+2+4+5+3+1=19 19x3=57 1+3+5+4+2=15 57+15=72 and 8 makes 80
In VBA/Visual Basic it looks something like this:
Dim checkDigitSubtotal As Integer ' check digit throwaway
' Valid input is 11-digits (no check digit), 12-digits (with check digit), or 14-digits (GTIN).
Select Case Len(UPCnumber)
Case 11
' do check digit calculation
Case 12
' lets ignore your check digit & use ours
UPCnumber = Left(UPCnumber, 11)
Case 14
' GTIN input, strip leading 2 characters & last one too;
UPCnumber = Mid(UPCnumber, 3, 11)
Case Else
' error handling goes here
End Select
' do the check digit
checkDigitSubtotal = (Val(Left(UPCnumber, 1))) + (Val(Mid(UPCnumber, 3, 1))) + (Val(Mid(UPCnumber, 5, 1))) + (Val(Mid(UPCnumber, 7, 1))) + (Val(Mid(UPCnumber, 9, 1))) + (Val(Right(UPCnumber, 1)))
checkDigitSubtotal = (3 * checkDigitSubtotal) + (Val(Mid(UPCnumber, 2, 1))) + (Val(Mid(UPCnumber, 4, 1))) + (Val(Mid(UPCnumber, 6, 1))) + (Val(Mid(UPCnumber, 8, 1))) + (Val(Mid(UPCnumber, 10, 1)))
Azalea_UPC_A_checkDigit = Right(Str(300 - checkDigitSubtotal), 1)
End Function
I assume this would be done via an update. If I'm wrong let me know.
I have some instructions and sample code (unfortunately it's in Visual Basic)
How would I make it go? see instructions and sample code below
Thanks in advance.
UPC barcodes include a check digit. The UPC check digit is the 12th digit in the lower-right corner of the barcode. Here's how to calculate a UPC barcode check digit
The last digit in a UPC barcode is a check digit based on the previous 11 numbers. Our example barcode data is "41234554321"
Add up the numbers in the odd positions left to right. Multiple the result by 3. Add up the numbers in the even positions. Now add the first subtotal to the second. The UPC barcode check digit is the single digit number makes the total a multiple of 10.
4+2+4+5+3+1=19 19x3=57 1+3+5+4+2=15 57+15=72 and 8 makes 80
In VBA/Visual Basic it looks something like this:
Dim checkDigitSubtotal As Integer ' check digit throwaway
' Valid input is 11-digits (no check digit), 12-digits (with check digit), or 14-digits (GTIN).
Select Case Len(UPCnumber)
Case 11
' do check digit calculation
Case 12
' lets ignore your check digit & use ours
UPCnumber = Left(UPCnumber, 11)
Case 14
' GTIN input, strip leading 2 characters & last one too;
UPCnumber = Mid(UPCnumber, 3, 11)
Case Else
' error handling goes here
End Select
' do the check digit
checkDigitSubtotal = (Val(Left(UPCnumber, 1))) + (Val(Mid(UPCnumber, 3, 1))) + (Val(Mid(UPCnumber, 5, 1))) + (Val(Mid(UPCnumber, 7, 1))) + (Val(Mid(UPCnumber, 9, 1))) + (Val(Right(UPCnumber, 1)))
checkDigitSubtotal = (3 * checkDigitSubtotal) + (Val(Mid(UPCnumber, 2, 1))) + (Val(Mid(UPCnumber, 4, 1))) + (Val(Mid(UPCnumber, 6, 1))) + (Val(Mid(UPCnumber, 8, 1))) + (Val(Mid(UPCnumber, 10, 1)))
Azalea_UPC_A_checkDigit = Right(Str(300 - checkDigitSubtotal), 1)
End Function
Comment