Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have a USB 2D scanner, and I want to read PDF417 barcode.
It returns an Asscii code so when I read it using a notepad many windows start to open.
I tried to use the same code as the regular barcode scanner with a Textbox and handled the KeyDown event but did not work too.
Can anyone help how to read this Ascii code???
C#
private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                var result = textBox1.Text;
                MessageBox.Show(result.ToString());
            }

        }
But this did not work.
Posted
Updated 6-Jun-13 18:28pm
v2
Comments
Sunasara Imdadhusen 6-Jun-13 8:22am    
please provide code snippet!!
Marc Gabrie 6-Jun-13 10:26am    
The focus should be on the textbox but try handling other events like TextChanged
Mohammad Al Hoss 6-Jun-13 16:19pm    
I will try and get back to you thanks.
Mohammad Al Hoss 8-Jun-13 10:55am    
I tried to do this
private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine(e.KeyChar.ToString()); //You can do other process here
e.Handled = true;
}
but still the returned Ascii code is sending events to the application and opening help windows and other stuff.
Marc Gabrie 9-Jun-13 8:19am    
Then maybe you need to handle any input in a global way. Try this

1 solution

You should do it at keypress event instead and cancel the key output to the textbox

C#
private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
	Console.WriteLine(e.KeyChar.ToString()); //You can do other process here
	e.Handled = true;
}
 
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