Question

  Asked: Aug 8 2006   5:03 PM GMT
  Asked by: mmm555


Barcode problem


C, Delphi, Visual Basic

Hi.
I have 2 problems in the software that i am doing:

1)I made a function on the textbox_changed so when he reads the barcode he will search in the database for the product info. The problem is that he is searching for each letter or number. ex: 56874474444 he will search after the 5, then after the 56 the after the 568 ... which will take time in a bid db. Whats the solution for such problem.
2)Also i have a problem while reading 2 barcodes that one of them is smaller than the second. ex: 7373 and 73738474, he will always give the info of the small one.
Thx.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



On the first part of the question, the scanner should be able to be setup to add a "postamble" to the barcode read, in that if the barcode is 123456789, the value returned would be 123456789[CR]. Then, you would check the last character in the text box to see if it is a [CR] and do the search at that point. (All the barcode readers I've worked with have had that capability.) This should take care of the second part as you would not be searching the database until the character(s) you had set up as the ending character(s) of the barcode is(are) sent to the textbox by the barcode reader. Remeber, also, to clear the value of the value in the textbox at the end of the search code, so that it can be ready for the next value to be sent from the barcode reader.

HTH,

Ed Lorden
Snorkel Software
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development.

Looking for relevant Development Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

CharlesJC  |   Aug 9 2006  8:25AM GMT

mmm555,

- For question #1: You can place your DB lookup code in the validate event of the textbox, as that is executed after input is complete vs. during input with the changed event.
- For question #2: You mentioned that when reading two different barcodes, of different lengths, that the information for the first barcode is returned. In your example the first barcode was a subset of the second. Does this happen if the two barcodes are completely different, like 7373 and 898432034)? Also, what is the sequence of evets when reading these two barcodes (what else is happening)? Are you reading the barcode into the same field? How much time elapsed between the reads?

Charles

 

AaronCutshall  |   Aug 11 2006  8:00AM GMT

First of all, do as suggested with the preamble and have the CR sent at the end of the data. Second, don’t use the Changed event at all because it fires for every change in the textbox including during character entry.

The approach I used is to have a hidden button with it set as the default object so that when the CR was received, the OnClick event would fire. I also set a global variable to the name of the current field in each barcode enabled field’s GotFocus event. That way when the button’s OnClick event fired, it would know what field it was in and process the data accordingly. Then would allow you to capture barcode information for multiple fields on the same form for a complete scan in each field.

HTH, Aaron