Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4340054
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:17:52+00:00 2026-05-21T11:17:52+00:00

I have an app that reads in a barcode from a USB scanner. I

  • 0

I have an app that reads in a barcode from a USB scanner. I want to do a DB lookup as soon as the barcode is entered in a particular textbox.

Clearly, I’m going to put my code in the TextChanged event handler, but I have a slight problem in that the barcode being read could be either 41 or 43 characters. The question is, how will I know which type of code is being entered. The scanner simply enters the code into whatever field has focus as a string of characters – as if it were entered by a keyboard – so I can’t query the scanner to determine the code length.

I’ve thought of two approaches so far:

  • Detect first character, wait x.x seconds, and then do my lookup – allow enough time for a full code to be entered
  • Detect the 41st character, wait 0.x seconds and then do my lookup.

OK, I’m sure these will work OK, but are there any more eloquent solutions?

CONCLUSION:

Some useful suggestions, however Ondrej has inspired the simplest solution for my scenario. The 43 char codes have two characters that are fixed for all codes – the presence (or not) of these two characters means I know to wait if these two characters are present but only 41 characters are present.

I just need to confirm my suspicion that the 41 character codes can’t have this pair of characters in this particular position – which I’m fairly sure is the case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:17:53+00:00Added an answer on May 21, 2026 at 11:17 am

    One option is to perform an Async lookup after the 41st character is read, while still waiting for two more characters in the UI thread. If you get a hit on that barcode you can stop waiting and show that result. Alternatively, if a 42nd character is entered while the lookup is in progress you can abort it and immediately begin a new lookup when the 43rd character is entered. This assumes, however, that no 43-character barcode begins with an existing 41-character barcode.

    I’d also look and see if the barcodes contain some pattern (for example: 41-char codes have an X as the 9th character and 43-char codes do not), and scan for that as it’s being entered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# console app App1 that reads a row of data from
I currently have an iPhone app that reads data from an external XML file
I have successfully created an app that reads from a bundled .plist file and
I have an HTML (App) file that reads another HTML (data) file via jQuery.ajax()
I have a simple C# Console App that reads in an XML file specified
What I have is a C# windows app that reads a bunch of SQL
Help me, Stackoverflow! I have a simple .NET 3.5 console app that reads some
I have an app that needs to scan a barcode to get a code
I have a SL application that reads some data from the database, which I
I have noticed in the android gesture examples, that it reads the gestures from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.