[RESOLVED] Barcode Scanning Into a Listbox
Hi guys. I was curious if you could help me with a program I'm trying to create.
I am creating a barcode scanning application. The barcodes contain a serial number and a quantity. What I want to do is be able to scan in a barcode using the scanner, and then have code that automatically runs and separates the serial number from the quantity and then throws it into a listbox.
The code to separate serial and quantity and put them into a listbox is already created, but what I cant figure out is how do I detect that a barcode has been scanned? I want this to be done without any input from the keyboard, and the scanner works like any other standard input device. I'm just not sure how to get my program to recognize a scan has occured and then automatically take the scanned data and do something with it.
Are there methods built in to Visual Basic.net that could help me with this, or am I going to need code from an outside source? I checked the scanner software to see if there was any sort of API with it, but couldn't find anything. I appreciate any help I can get on this. This is definitely a learning experience. Thanks!
Re: Barcode Scanning Into a Listbox
Well, I have created barcode applications in the past and a barcode scanner is treated
like keyboard input.
So, the part about without any input from the keyboard - Im not sure how you're going
to accomplish that one.
As far as how to detect if a barcode was scanned, I would have an area that they scan in, and make it a textbox and use the textchanged event.
Re: Barcode Scanning Into a Listbox
This question has came up before a few times in the past as well. If you use the search function in this forum and search for "barcode" or "bar code" in the VB.NET forum specifically, you should pull several threads...
Re: Barcode Scanning Into a Listbox
can you dont use an temp textbox and use the textchanged property of the textbox to know when the barcode is scanned..
hope this vil help
Re: Barcode Scanning Into a Listbox
Thanks for the help guys. I should have done a search on the forums before posting this, because I found exactly what I needed. The scanner adds a carriage return after each scan, so checking for the enter key press worked perfectly. Here is the code that was used (taken from another post on this forum but here it is again):
Private Sub txtTest_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBarcode.KeyDown
If e.KeyCode = Keys.Enter Then
Dim barcode As String
barcode = txtBarcode.Text
lstbxQueue.Items.Add(txtBarcode.Text)
lblItemsCount.Text = myForm2.lstbxQueue.Items.Count
txtBarcode.Focus()
End If
End Sub