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

When read qr using barcode scanner for more than one it append the same textbox4 .

i need to clear data after every scanning done .


I using usb scanner reader qr code with type metro logic working as keyboard

and using USB

i read data in textbox4 key down success

but problem if i read data for new qr code

it append in same text box

so that what i do to clear the data recieved before and prevent append to old

my code

private void textBox4_KeyDown(object sender, KeyEventArgs e)

                string[] lines = textBox4.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            if (lines.Length > 4)
                textBox1.Text = lines[1].Substring(lines[1].IndexOf(":") + 1);
                textBox2.Text = lines[2].Substring(lines[2].IndexOf(":") + 1);
                textBox3.Text = lines[3].Substring(lines[3].IndexOf(":") + 1);
                textBox5.Text = lines[4].Substring(lines[4].IndexOf(":") + 1);

textbox4 read data from reader device then split them to textboxes

What I have tried:

How to clear data readed by scanner from textbox to recieve another one?
Updated 20-Feb-17 12:41pm

1 solution

In general, there are two ways to clear a textbox - using your case


textBox4.Text = string.Empty;

this issue is I'm not sure of your logic/program flow, and thence 'where' to do this in your code

[edit] I guess you do it before this/the new read "
but problem if i read data for new qr code
happens, but you havnt shown much 'code' so I dont know where that is in your program [/edit]
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