title: Automatically send barcode scanner input to textbox VB.Net / Winforms
body: <p>I've reviewed dozens of options/solutions on this and I just can't get it to work.</p>
  
  <p>Simply put, I have a VB.Net Winform that has a textbox where a user can manually type in text or they can use a USB connected barcode scanner (that simulates a keyboard) to capture a UPC.</p>
  
  <p>What I'm trying to do is get the barcode input to get entered into the textbox regardless of which control has the current focus.</p>
  
  <p>I have set the KeyPreview property of the form to True.</p>
  
  <p>I then added some code to the frmMain_Keypress event as follows:</p>
  
  <pre><code>    If Me.txtSearch.Focused = False Then
          txtSearch.Focus()
      End If
  </code></pre>
  
  <p>Very simple...and it works, sort of...</p>
  
  <p>If txtSearch already has the focus, the entire barcode/UPC gets entered into the text box.</p>
  
  <p>However, if another control has the focus, every character of the barcode/UPC <strong>EXCEPT THE FIRST CHARACTER</strong> gets entered into the text box.  It always strips off the first character.</p>
  
  <p>I placed some debug statements in the above code to see if the initial character was being read at all and it is being read...just not sent to the text box.</p>
  
  <p>I've seen so many other REALLY complicated solutions to barcode scanning and it seems like I'm really close with something really simple, but, obviously it won't work if it strips the leading character.</p>
  
  <p>Hopefully I'm missing something very obvious.</p>