Click here to Skip to main content
15,884,794 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I am developing a system in Windows Form, where there will be a report and a field will be a barcode. The problem is that when I pass the numeral 123456789 through the bar code parameter, it is created, but I can't read the code at all. I read on various forums how to do the calculation. But I can't implement it at all.
Where am I going wrong?


What I have tried:

public string ReturnCode128(string text)
        {
            const int codetype = 105;
            string textcode = text.Trim();
            int quantidade = textcode.Length;
            int[] arrayintcode = new int[quantidade];

            for(int i = 0; i < quantidade; i++)
            {
                char valToConvertToASCII = Convert.ToChar(textcode[i]);
                int valToMultiply = valToConvertToASCII- 32;
                arrayintcode[i] = valToMultiply;
            }

            string[] codemulti = new string[quantidade + 3];
            codemulti[0] = codetype.ToString();
            for(int i = 1; i < quantidade+1; i++)
            {
                codemulti[i] = (i*arrayintcode[i-1]).ToString();
            }

            int value = 0;
            for(int i = 0; i < codemulti.Count(); i++)
            {
                value += Convert.ToInt32(codemulti[i]);
            }

            int module = value % codetype;

            char charverify = (char)(module + 32);

            char start = (char)186;
            char stop = (char)186;

            return $"{start}{textcode}{charverify}{stop}";
        }
Posted
Comments
SeanChupas 12-Apr-21 16:21pm    
I do not understand what you are asking.
Member 11426986 13-Apr-21 6:57am    
I have an rdlc, where inside the rdlc there is a textbox with the code128 font. When I call rdlc with the reportviewer, I pass a text field as a parameter, and that parameter is what goes in the barcode. However, if I send "123456789", it will form the barcode, but I can't read it.
Member 11426986 13-Apr-21 6:59am    
I use this method to inform the text field (123456789) and it returns me how the bar code should look. But when I try to beep, the code doesn't read.
SeanChupas 13-Apr-21 8:51am    
Have you compared the barcode to one that is valid? Maybe you have a width set and so it's getting stretched or compressed?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900