VB.NET: Reading Barcode into Another Control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BobDude
    New Member
    • Oct 2006
    • 4

    VB.NET: Reading Barcode into Another Control

    Howdy.

    I'm trying to read a barcode using a IE scanner.
    The code is read into a textbox.

    I use the textchanged event to trigger code behind so the barcode numbers are transferred into a dropdown list.
    The only issue is that the event must look at each individual character. The DD list is then populated with a progrssive list of all the characters in the barcode.

    How does .NET see the characters coming in?
    Am I using the correct event to read the barcode?

    Thanks
  • DeWittds
    New Member
    • Oct 2006
    • 11

    #2
    Bobdude,
    I am currently working on the same type of thing. What I did was have it do "whatever" when the textbox lost focus. And then in my case reset the focus and select all to the same text box so it is ready to except another barcode. Let me know if you need more info. This happens to be the first thing I have done in vb.net and have not had to write any since vb5.

    Dave

    Comment

    • BobDude
      New Member
      • Oct 2006
      • 4

      #3
      ------

      Thanks for the comeback, Dave.

      My scanner input is really primative right now.
      When I scan a barcode, I know the _TextChanged sub is executed which loads a textbox with the digits, one character at a time.
      All I do now is check to see if the length of the textbox is = 12.
      Then it runs a _Validated sub that adds the 12 characters in the textbox to a dropdown list.
      Then it clears out the Textbox.

      One issue I have is trying to determine how long the input really is, in case the barcode scanned is not equal to 12. If I can determine when the character input stops, then I can dispense with the length check of 12 and just add the code to the dropdown list.

      Any ideas how to do that?

      Thanks - BD

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I find that in a situation like this it can be helpful to write out a message (preferably to a text file, or maybe just the debug window) in every event for the control in question, and any events for the form that sound like they could be relevant. Then perform your action, then scan the log and see exactly what events happened, in which sequence.

        Being shown in this way exactly what events fire sometimes makes it obvious which one(s) to use.

        (Note, using a MsgBox or similar to show on the fly what's happening can actually change the sequence of events.)

        Comment

        • jbarbara
          New Member
          • Oct 2007
          • 1

          #5
          I set up the barcode device to add a suffix to the data being read - something that will never be part of the data. In my case I chose the dash sign ( - )

          Then in the etextbox_change d event I just check whether the input box endswith "-" and if so I chop off the "-" and copy the contents of the texbox to wherever.

          My problem is that the device is suddenly adding an extra "S" at the end, and since it's being added AFTER the dash, I would have already cleared the textbox, and end up with the S there - jeopardizing my next barcode scan.

          Funnily enough this only happened with three barcodes out of 500.

          I wonder if I can clear the keyboard buffer within VB.NET

          Anyone has an idea?

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Just a thought - perhaps this is a glitch in the scanner and needs servicing. You can't really reqwrite your software to deal with every possible thing that goes wrong with the hardware.

            Comment

            Working...