Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using c# and i want to develop barcode reading application for pos.
I am not able able identify last character. Can anyone help me with sample code

What I have tried:

now it working with text changed event. The problem is
suppose 1 barcode like 12345678 and second item barcode is 12345
when i am scanning first item , it read second item when it reach 5 letter of barcode
Posted
Updated 1-Jun-18 22:32pm
Comments
[no name] 3-Jun-18 13:24pm    
Maybe you're scanning "too fast".

Or not sending the proper "command code sequences" (before and / or after a good / bad scan).

Barcodes are not a "fixed length" - there are several different types which encode a different number of digits (in fact, some can contain a whole load more than just digits: EAN128 can contain heaps of information if needed) and five digits is a "valid" barcode number (ish, it's supposed to be leading zero padded to a minimum of 8 digits, plus a checksum digit at the end)

I'm assuming that you are using a "standard" barcode scanner instead of making your own hardware? In which case, the data is almost certainly arriving as if it was entered from a keyboard, and that means that the TextChanged event will occur repeatedly as digits arrive - they don't all appear at once as if by magic, any more than they would if you actually typed the article number!

What I would do is check the documentation on your scanner (or talk to the manufacturer) and find out how to add "lead in" and "tail out" codes to the barcode data it sends - that way you can positively check the incoming data and identify where a barcode starts and stops using the KeyPress event, instead of relying on TextChanged to detect something.
 
Share this answer
 
Quote:
I am not able able identify last character.

Probably because most barcodes are variable length, you have to know what barcode you are reading.
Quote:
now it working with text changed event.

Hope you don't use the scanner as keyboard entry, it is the worst thing to do because cursor wrong position is enough to mess the input.
Usual usage is to configure the barcode as serial communication and have your code handling that part without messing with GUI. And one send the barcode to GUI only once you know it is complete.
Quote:
Can anyone help me with sample code

The maker of scanner should have some sample code
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900