G
grohotanie
I'm trying to print out barcodes within my program using Code128B
fonts
The code is something as follows:
strDocID = CalculateCheckSum(strDocID);
CRect rectBarcode = PrintText(pDC, rectFolder.bottom+m_nTextSpacing *
10, rect, strDocID, ALIGN_CENTER);
CString PrintContainerLabel::CalculateCheckSum(CString barcode)
{
int checkSum;
CString Code128b;
char letter;
int val = 104;
checkSum = val;
for (int i = 0; i < barcode.GetLength(); i++)
{
letter = barcode.GetAt(i);
val = letter;
val -= 32;
checkSum += val * (i + 1);
}
int moduloValue = checkSum % 103;
moduloValue += 32;
Code128b = char(202);
Code128b += barcode;
Code128b += char(moduloValue);
Code128b += char(138);
return Code128b;
}
something that I absolutely can not figure out is that it doesnt work
for "1593387" - prints out a weird character at the end of my barcode.
For any substring of this or if I add any more values, miraculously
starts working.
If anybody has any suggestions, I would greatly appreciate!
Anton
fonts
The code is something as follows:
strDocID = CalculateCheckSum(strDocID);
CRect rectBarcode = PrintText(pDC, rectFolder.bottom+m_nTextSpacing *
10, rect, strDocID, ALIGN_CENTER);
CString PrintContainerLabel::CalculateCheckSum(CString barcode)
{
int checkSum;
CString Code128b;
char letter;
int val = 104;
checkSum = val;
for (int i = 0; i < barcode.GetLength(); i++)
{
letter = barcode.GetAt(i);
val = letter;
val -= 32;
checkSum += val * (i + 1);
}
int moduloValue = checkSum % 103;
moduloValue += 32;
Code128b = char(202);
Code128b += barcode;
Code128b += char(moduloValue);
Code128b += char(138);
return Code128b;
}
something that I absolutely can not figure out is that it doesnt work
for "1593387" - prints out a weird character at the end of my barcode.
For any substring of this or if I add any more values, miraculously
starts working.
If anybody has any suggestions, I would greatly appreciate!
Anton