# CR10 - Check Digit with Weight Using 7,5,3,2

Hello:

I need help with the formula attached - I need to change it from Calculating "Double Every Second Digit" to using the 7,5,3,2 Check Digit Weight, repetition starting from the first number on the left of the scan line.

Any ideas would be great.  I'm at a loss on how to do this at this point.

Thank you!

** Attached Document Contains Example from Bank and the original formula.
Check-Digit-Weights.docx
###### Who is Participating?

Commented:
Actually the sum of the products is 216  (127 + 45 = 172 not 162)
Here is the code to get the check digit for the give string

``````Local StringVar ScanNumber := '544969302100002500';
Local NumberVar Array Multipliers := [7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2];
Local NumberVar CheckDigitTotal;
Local NumberVar Index;
Local NumberVar ConstantValue := 8;

CheckDigitTotal := 0;

For Index := 1 to Length(ScanNumber) do
CheckDigitTotal := CheckDigitTotal + Val(ScanNumber[Index]) * Multipliers[index];

CheckDigitTotal := CheckDigitTotal + ConstantValue;
CheckDigitTotal MOD 10
``````

For a string from the database use
``````Local StringVar ScanNumber;
Local NumberVar Array Multipliers := [7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2];
Local NumberVar CheckDigitTotal;
Local NumberVar Index;
Local NumberVar ConstantValue := 8;

ScanNumber := {Yourfield};
CheckDigitTotal := 0;

For Index := 1 to Length(ScanNumber) do
CheckDigitTotal := CheckDigitTotal + Val(ScanNumber[Index]) * Multipliers[index];

CheckDigitTotal := CheckDigitTotal + ConstantValue;
CheckDigitTotal MOD 10
``````

The code will handle a 32-digit numeric string.  If you need more just exted the Multiplier array with more 7532's

You can change the constant as desired or even set it to a database field or parameter

mlmcc
0

Commented:
Are all the numbers the same length? (19 digits in the example)

WHere does the answer 214 come from?  The sum of the products is 206.

Can you confirm that the field containing the number is being seen by Crystal as a text field.
0

Consultant/ControllerAuthor Commented:
Thank you!!!  This worked perfectly.

Awesome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.