|
-
Jan 30th, 2006, 08:52 AM
#1
Thread Starter
Hyperactive Member
What event does a barcode reader fire off?
I am trying to figure out how to do an automatic inventory look up using a barcode reader. Right now I have items in my database that I can retrieve by scanning an item and then tabbing out of the textbox with code like this.
VB Code:
Private Sub txtBarcode_Leave(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles txtBarcode.LostFocus
LookUpItem()
End Sub
However, I want to be able to scan an item and have the lookup happen automatically without the user having to press tab, enter or mouse out of the text box. I have tried various textbox events but none have done what I need it to do.
After a scan an item I do get a sound like the scanner is trying to fire an event but the program doesn't know what to do with it. Any ideas?
-
Jan 30th, 2006, 08:55 AM
#2
Re: What event does a barcode reader fire off?
The TextChanged event should fire when the barcode reader fills the text box.
-
Jan 30th, 2006, 09:01 AM
#3
Re: What event does a barcode reader fire off?
Most barcode scanners are connected to the keyboard port, although more and more are and will be USB. Basically, using a barcode scanner is akin to typing the same characters in from the keyboard. I could be wrong but I'm guessing that the TextChanged event will be raised for each character in the barcode, as opposed to just once for the whole thing.
-
Jan 30th, 2006, 09:56 AM
#4
Thread Starter
Hyperactive Member
Re: What event does a barcode reader fire off?
jmcilhinney you are correct. The text changed does raise an event for each character in the code. The reader I am using is a USB device and as you stated it essentially a series of keyboard entries.
The more I have played with this device the more I am sure that that it is adding an "enter" at the end of the barcode. How would I go about trapping that enter and using it to do the look up?
-
Jan 30th, 2006, 10:40 AM
#5
Re: What event does a barcode reader fire off?
instead of text_changed you could try using the keyPress event and then check if the KeyPress was a Carriage return and if it was then call LookUpItem().
VB Code:
if e.KeyChar = 13 then
'If return key call LookUpItem()
End if
-
Jan 30th, 2006, 11:17 AM
#6
Thread Starter
Hyperactive Member
Re: What event does a barcode reader fire off?
Thank you. This is what I ended up with
VB Code:
Private Sub txtBarcode_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles txtBarcode.KeyDown
If e.KeyCode = Keys.Enter Then
LookUpItem()
ListBox1.Items.Add(lblItemName.Text)
txtBarcode.Clear()
txtBarcode.Focus()
End If
End Sub
-
Jan 30th, 2006, 12:54 PM
#7
Re: What event does a barcode reader fire off?
Just a thought - Last time I made an app for a barcode scanner, I got stuck with one that couldn't be programmed to put enter after the read. I used a timer to find out how long it had been since the last character was entered, and if it was more than a second, I processed the barcode. Hopefully they'll stick with the one you've got
Bill
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|