kierenj
unread,Sep 24, 2008, 5:10:09 AM9/24/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I've implemented barcode scanning in a recent project for a client.
Indeed it does work as a keyboard. The difficulty with this is, if
you are validating a barcode, or it has to be a specific length.. you
can't tell if the user is simply typing something, scanning a bad
barcode, etc. If you want 10 digits and set a textbox limit, what if
the user scans a 15 digit barcode (you won't know), or a 5 digit one,
followed by the correct 10 digit one (you'll get half of each).
What I found best is to create a user control, kind of like a stateful
textbox wrapper, specifically for barcodes. You can implement it like
this:
* Textbox, unlimited length
* Timer, set to ~500ms: check for valid barcode (length-wise, etc) -
if it's there, disable timer, fire event, run barcode processing
method, etc. If not, CLEAR the textbox text
* OnTextChanged event: disable, then re-enable the timer
This means if you scan an invalid code, it's cleared out after 500ms.
If the user has to be able to type a barcode too, they will have to
enter each keypress within 500ms, so you could modify that value or
have a 'manual entry' link with simple entry dialog.
Hope this helps.