Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping data from USB scanner

Status
Not open for further replies.

BlackburnKL

Programmer
Oct 21, 2002
196
0
0
US
I am designing a form for an application in C# 2005 which receives input from a USB barcode scanner (which seems to treat the data as if it had been entered from the keyboard--without the usual key down/up/press events, of course).

I would like to be able to allow the user to scan multiple barcodes (with unique data lengths for each type of data I want to capture) and allow the program to trap the incoming data stream and determine its length and to programmatically place it into its corresponding control on the form.

For simplicity's sake, let's assume that I want to scan product codes and defect code for a quality inspection. Let's further assume that I have a single TextBox on my form (for receiving the input from the scanner) and two labels on my form (one for displaying the product codes scanned and another for displaying the defect codes scanned).

I simply want to scan a product code, then all of the defect codes for that quality review of that product, then scan the next product code and its defect codes, etc. Scanning two product codes in a row would indicate no defects found. Scanning a defect code prior to any product code would be rejected by the programming.

BlackburnKL
 
Where's the question here?

You just defined your rule-set. Now you just have to program it.

If you are interested in creating your own barcodes by the way, download the Free3of9 true type font and surround your barcodes with *

*123456789*

When scanned will produce 123456789 as if it had been typed in a keyboard.

 
Sorry that I didn't make it clear. The description of the application was a poor attempt to provide additional details.

As the subject line(Trapping Data from USB Scanner) indicated, I am looking for a way to trap the data from the USB scanner and to know that I have a complete scan.

I have considered the TextBox's .TextChanged event, but the characters come in one at a time (much like if they were typed from the keyboard). What I need to know is when the scan is complete. I was hoping for something that would read the keyboard buffer so I could programmatically determine which type of code had been scanned before the next code could get scanned. The .TextChanged event places the scanned data one character at a time into the TextBox without a good way to identify when one scan stops and another starts if they happen close together.

Perhaps a timer could spot gaps between characters, but I hope that there is an easier way. I am more used to dealing with serial port scanners where I open the serial port and read individual scans, but I haven't found a way to do that with a USB port. Is there an easier way to read individual scans from a USB scanner?

Hopefully it is a little clearer now.

And thank you for your response and desire to help. I do appreciate your input.

BlackburnKL
 
most (if not all) USB scanners can be programmed to send a Carriage return/Line Feed at the end of the barcode. This really shouldn't be an issue...
what model do you have?

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks, whosrdaddy, for your insight. I had wanted to avoid adding a delimiter, but that is probably the best approach under the circumstances.

BlackburnKL
 
The others I've seen act as if they were a 2nd keyboard, and they just feed their input into whatever field on the form has focus.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top