Click here to Skip to main content
15,917,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

i have a task on read bar code and insert to database.

exp:
barcode : abc

my problem is when i scan on the barcode to textbox.
the value i get is 'a', then 'ab', then 'abc'

any ideas that i can get the barcode value 'abc', then fire the action.
*my barcode is in dynamic length.
Posted
Comments
CHill60 9-Oct-13 7:49am    
Try using the Improve question link to post your code
CodeBlack 9-Oct-13 8:13am    
how do you store it in database ? I think you store it in onchange event of textbox right ? and are you using web application or windows application ?

1 solution

Barcode scanners I have used in the past put a carriage return + newline (i.e. "\r\n") at the end of the text so I use the KeyDown event and check for the Enter key to wait for the full barcode to be submitted:

C#
private void tbEnterSerialNum_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        string serialnumber = this.tbEnterSerialNum.Text;

        // now do enter it into the database...
    }
}
 
Share this answer
 
v2
Comments
Member 10235666 10-Oct-13 1:47am    
i am using window application.and i want fully automatic their no need to press any key .i have done on textbox leave event it works but their is need to press tab key.

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