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. On 22 Sep, 00:18, Badawi <[EMAIL PROTECTED]> wrote: > Hi all of you, > > I'm a newbie in C#.NET development and i need help in handling barcode > scanners within C# application. > How i can read barcodes from a barcode scanner (both types USB and PS/ > 2)? > And if there is a way to read barcodes independently on the scanner > type (USB or PS/2), i will be so happy to know. > > thanks in advance, > Badawi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://cm.megasolutions.net/forums/default.aspx -~----------~----~----~----~------~----~------~--~---
