printint problem

Discussion in 'C++' started by grohotanie@gmail.com, Oct 4, 2007.

  1. Guest

    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
     
    , Oct 4, 2007
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > 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);
    >

    This looks like windows specific code which makes it OT here, you would
    get better responses on a windows programming group.

    --
    Ian Collins.
     
    Ian Collins, Oct 4, 2007
    #2
    1. Advertising

  3. Jim Langston Guest

    <> wrote in message
    news:...
    > 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


    Most likely your checksum calculation is wrong and for 1593387 it produces a
    value outside of the barcode char set. Try taking a look at moduloValue for
    ones printed correctly and ones with this "weird character".
     
    Jim Langston, Oct 5, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Suurkuusk
    Replies:
    0
    Views:
    4,003
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,184
    Ted Miller
    Sep 13, 2003
  3. Diego F.

    Printint datagrid: last row cut

    Diego F., Jun 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    389
    Diego F.
    Jun 8, 2005
  4. James H. Markowitz

    Printint out a macro's expansion

    James H. Markowitz, Dec 25, 2009, in forum: C Programming
    Replies:
    3
    Views:
    486
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    561
    Bullschmidt
    May 11, 2004
Loading...

Share This Page