Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Problem

Barcode scanner return only first digit only why and How to Return Full Number as 6221133347389 

6221133347389 return 6
4716201020476 return 4

screen shoot debug
<a href="http://www.mediafire.com/view/1bjtifib1kq3ahg/Capture.JPG/file">File sharing and storage made simple</a>[<a href="http://www.mediafire.com/view/1bjtifib1kq3ahg/Capture.JPG/file" target="_blank" title="New Window">^</a>]

Barcode read 2d for Items 

Barcode Device DataLogic Lite QW2100

MODEL QY2100

CLASS QY2120-BK

S/N G17079019

when reading  ItemCode '       6294004851032' by barcode scanner it return 6 only as first digit

why it return first digit only 

i need to return full number .

What I have tried:

<pre>DateTime _lastKeystroke = new DateTime(0);
    List<char> _barcode = new List<char>(20);
public PosFrm()
    {


        InitializeComponent();
        this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.PosFrm_KeyPress);

    }
private void PosFrm_KeyPress(object sender, KeyPressEventArgs e)
    {
        TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
        if (elapsed.TotalMilliseconds > 100)
            _barcode.Clear();

        // record keystroke & timestamp
        _barcode.Add(e.KeyChar);
        _lastKeystroke = DateTime.Now;
        //		e.KeyChar	52 '4'	char

        // process barcode
        if (e.KeyChar == 13 && _barcode.Count > 0)
        {


            string msg = new String(_barcode.ToArray());
            MessageBox.Show(msg);
            _barcode.Clear();
        }
    }
Posted
Updated 9-Sep-18 19:33pm

1 solution

We can't tell - we don't have your scanner, and we can't run your code as a result.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

If that doesn't help (and it may not, because your scanner is generating keystrokes, which won't all go to your app once the debugger hits a breakpoint) you will have to fall back on older methods and start "peppering" your code with Debug.WriteLine statements to give you a chance to "follow" exactly what happened when you scanned a code.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

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