How Can I fix code 128 B checksum exceeds Ascii code range C#

60 views Asked by At

i have printed barcode using code 128 B type. However, some text cannot be read.

some text's checksum value exceeds ascii code range..

How do i Recalculate checksum when it is exceeded ascii code range??

here my code

//Code 128 B
//Start Code (intSOD) : 104
 intSUM = intSOD; //intSOD : 104

//barcodeStr = CNYTAI0008
// intpBARCODE = barcodeStr.length

 for (int i = 0; i < intpBARCODE; i++) 
 {
     int intVAL = 0;
     intVAL = barcodeStr[i]; 
     intVAL = intVAL - 32; 
     
   Console.WriteLine(string.Format("Text : {0} : [ {1} ]" , barcodeStr[i] , intVAL));

     intSUM = intSUM + intVAL * (i + 1);
 }
    intMMM = intSUM % intMOD; //intMOD is 103
    strSUM = Char.ToString((char)(intMMM + 32));

  Console.WriteLine(string.Format("CHECK SUM  :  {0} % {1} = {2}  --> [ {3} ]", 
  intSUM.ToString(), (intMOD).ToString(), (intMMM).ToString(),strSUM));

 //result
 CHECK SUM  :  1645 % 103 = 100  --> [ ? ] 
 //final check sum value is 132 , <-- How can i recalculate?? 
1

There are 1 answers

0
Jeremy On

I've had the same issue, and after having play a bit, for me the solution was to use the "Code B" value (character È) instead of the checksum when the result of the remainder was above 96.

I don't know if this is the official way to doing it, but I've tried with quite a lot of codes and since then I had good readings at any time.

Hopfully it will help you and some others.