troubleshooting Question

# asp script Check digit calculation - 20 digit barcode

ASP
Hi

I am writing in asp and have a 19 digit code which i need to formulate to create a check digit for a barcode,

I have the formula, but have no idea on how to write this in asp.

my 19 digit barcode for the example is: 9673169126799000001?

the above number is stored in my database as 'barcode'

the check digit is calcualted based on the formula known as Modulus 10, factor 3:

NB. the positions are numbered from RIGHT to LEFT therefore the checkdigit is in position 1

Operation 1
Starting from position 2 of the barcode, add the digit values in even positions

Operation 2
Multiply the result of operation 1 by 3

Operation 3
starting from position 3 of the code, add the digit values in odd positions

Operation 4
add the results of operation 2 & 3

Operation 5
The check digit is the smallest number, which when added to the result of operation 4, gives a multiple of 10.

Example

Barcode number: 9673169 12 6799 000001?

Operation 1: 1+0+0+9+7+2+9+1+7+9  =45

Operation 2: 45 x 3                             =135

operation 3: 0+0+0+9+6+1+6+3+6      =31

Operation 4:135 + 31                          =166

Operation 5: 170 - 166                       =4

Check digit = 4

TimCottee
Applications and Integrations Consultan
###### Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.