title: Auto clear textbox after barcode input and passing the value to a string
body: <p>this is my first time to use this barcode reader hardware. Im having a problem in auto clear the textbox after barcode input. It clears the textbox before it passes the value to a respective string.</p>
  
  <pre><code>private void txtStudentID_TextChanged(object sender, EventArgs e)
  {
      string a = txtStudentID.Text;
      sqlDisplayInfo = a;
      txtStudentID.Text.Clear()
  }
  </code></pre>
  
  <p>I also tried using thread but it fails</p>
  
  <pre><code>private void txtStudentID_TextChanged(object sender, EventArgs e)
  {
      string a = txtStudentID.Text;
      sqlDisplayInfo = a;
      Thread.Sleep(1000);
      txtStudentID.Text.Clear()
  }
  </code></pre>
  
  <p>EDIT for my new code:</p>
  
  <p>i have problem here +=. example i scanned a barcode then it combines the previous scan and the next scan</p>
  
  <p>i use timer tick but it is not perfect as it is because sometimes it cause delay in retrieving the data in the database, so it does not collaborate with the time intervals</p>
  
  <pre><code>private void txtStudentID_TextChanged(object sender, EventArgs e)
          {
              timer1.Interval = (700);
              timer1.Enabled = true;
              timer1.Start();
          }
  
          private void timer1_Tick(object sender, EventArgs e)
          {
              timer1.Stop();
              a = txtStudentID.Text;
              displayData(a);//passing string a to method data retrieve
              timer2.Interval = (700);
              timer1.Enabled = true;
              timer2.Start();
          }
  
          private void timer2_Tick(object sender, EventArgs e)
          {
              if (!string.IsNullOrWhiteSpace(this.txtStudentID.Text))
              {
                  timer2.Stop();
                  txtStudentID.Clear();
              }
          }
  </code></pre>