Capture barcode input in Textbox
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Capture barcode input in Textbox

  1. #1
    Join Date
    Nov 2009
    Posts
    14

    Capture barcode input in Textbox

    Hi,

    I have a USB scanner that I use to input into a textbox. The issue is that I'll need to check for a barcode that is 6 digits long and another that is 9 digits long. Since the characters come in one at a time the 6 char length condition will always be satisfied. Has anyone had to deal with something like this?

    Code Samle:

    Code:
        private void txtTicketID_TextChanged(object sender, EventArgs e)
        {
    
    
          if (txtTicketID.Text.Length == 9)
          {
                .....
          }
    
    
          if (txtTicketID.Text.Length == 6)
          {
                .....
          }

  2. #2
    Join Date
    Jun 2009
    Posts
    144

    Re: Capture barcode input in Textbox

    maybe you can do it like this...

    Code:
        if (txtTicketID.Text.Length > 8 &&  txtTicketID.Text.Length < 10)
          {
                .....
          }
    
    
          if (txtTicketID.Text.Length > 5 && txtTicketID.Text.Length < 7)
          {
                .....
          }

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Capture barcode input in Textbox

    Can't you just read from the scanner until it is done and then update the textbox?

  4. #4
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: Capture barcode input in Textbox

    Even Spock couldn't write the logic for that.

    As Ed says, you need to read all of the characters from the Barcode reader before processing it. If the reader can read Barcodes that translate to either 6 or 9 or N digits, there must be a termination character included in its output?
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center