PDA

View Full Version : Check Digit Routine

ctaylor@colortech
November 18th, 2009, 06:19 AM
Has anyone had experience with writing a check digit routine? I need to write a modulus 10 check digit routine and I am fairly inexperienced with Javascript and could any help you may have. Thanks in advance. :confused:

ctaylor@colortech
November 18th, 2009, 09:55 AM
I was able to figure it after all. If anyone needs this for the future, I have included the code.

digit1 = StringToNumber(Left(Field("ID ENTITY FEIN1"), 1));
digit2 = StringToNumber(Right(Field("ID ENTITY FEIN1"), 1));
digit3 = StringToNumber(Left(Field("ID ENTITY FEIN2"), 1));
digit4 = StringToNumber(Mid(Field("ID ENTITY FEIN2"), 2, 1));
digit5 = StringToNumber(Mid(Field("ID ENTITY FEIN2"), 3, 1));
digit6 = StringToNumber(Mid(Field("ID ENTITY FEIN2"), 4, 1));
digit7 = StringToNumber(Mid(Field("ID ENTITY FEIN2"), 5, 1));
digit8 = StringToNumber(Mid(Field("ID ENTITY FEIN2"), 6, 1));
digit9 = StringToNumber(Right(Field("ID ENTITY FEIN2"), 1));
result1 = digit1 * 1;
result2 = digit2 * 2;
result3 = digit3 * 1;
result4 = digit4 * 2;
result5 = digit5 * 1;
result6 = digit6 * 2;
result7 = digit7 * 1;
result8 = digit8 * 2;
result9 = digit9 * 1;
result1a = FormatNumber("00", result1);
result2a = FormatNumber("00", result2);
result3a = FormatNumber("00", result3);
result4a = FormatNumber("00", result4);
result5a = FormatNumber("00", result5);
result6a = FormatNumber("00", result6);
result7a = FormatNumber("00", result7);
result8a = FormatNumber("00", result8);
result9a = FormatNumber("00", result9);
checkdigit = digittotal % 10
if (checkdigit == 0)
return "0";
else
return 10 - checkdigit;