Re: Barcode scanner with C#
Most wedge type scanners such as you describe have the ability to add a suffix to the data scanned. Typically the way you would handle this is to set the scanner to send a CR after the data then in the keypress event check to see if a CR was entered and if so then call whatever sub to process the data.
Of course you could do this with any character or if the barcode is fixed length you could even do it based on the length of the barcode.
Re: Barcode scanner with C#
Quote:
but my question is this: when a scanner reads some code (like 38503085 <-barcode) how do i trigger an event (something similar to KeyPress but actually this is a string).
so i use these codes (from barcode scanner) as an ID for a member and when i read a certain barcode i want that member to be displayed in form. (i dont want to make a textbox, focus it, get the barcode string there and press enter)
instead of Writing in Keypress event you handle it in Timer_Tick Event.Like The following .
Code:
privatevoid timer1_Tick(object sender, EventArgs e)
{
if (txtbarcode.Text.Length >= 12)
{
PrintLabel(); 'if you want to print in form .you can apply the same
}
}
:wave:
Re: Barcode scanner with C#
No you don't need to use a timer.
A wedge scanner fires the leypress event with every character. The there is no need nor point in using a timer. Most of these scanners come with a manual in which there is usually some barcodes you scan for configuration one of which should give you an enter keypress.
Re: Barcode scanner with C#
Quote:
No you don't need to use a timer.
A wedge scanner fires the leypress event with every character. The there is no need nor point in using a timer. Most of these scanners come with a manual in which there is usually some barcodes you scan for configuration one of which should give you an enter keypress.
Can you post some code ?.What are you trying to explain ?:wave:
Re: Barcode scanner with C#
I am not going to write the code but it is very very simple.
1: Configure the device to add a CR after each scan.
2: Place code in the keypress event to check if the keypressed is the enter key.
3: Place whatever code you want to process the barcode when the test is true.
As for configuring the device that depends on the device but I have never saw one that did not have this capability. Normally there are several barcodes in the manual that you can scan to setup the device. They will normally allow you to set it for the type of barcodes you want to decode and normally allow you to add a prefix and/or suffix to the data. In this case you would add a CR as the suffix so the device will send a CR after each decoded string.
Re: Barcode scanner with C#
sorry, as my project is due this friday, so I have no time to start a new discussion and wait for others to find that new thread. Here is my problem
I am working on a project that updates the records in my database from a barcode scanner, at the moment when you scan an item it places the barcode ina textbox on my form. Which needs a button click to submit the record to the database. and I am trying to achieve this: once the item has been scanned for the record to be inserted into the database without having to manually clicking a button.
So please give me some feasible advice, thank you so much.
Re: Barcode scanner with C#
barcode addict: Actually it's more probable that you will get replies faster if you start new threads.
The laziest possible thing you could do would be to just have the method that populates the textbox call the button's click event handler method (e.g. Button_Click(...)). Alternatively, you could just put the button click code on the end of the barcode scanner's event handler. If the barcode is read in character-by-character, you might need to do some sort of checking or validation to see when the complete code has been read.
Simple enough?
Re: Barcode scanner with C#
That is actually covered in the post #6. Simply have the scanner append a CR to the end of the barcode then in the keypress event look for the CR and call the code to insert your record. Assuming of course you are talking about a Wedge type scanner I.E. one that mimics keyboard input. Other types of scanner interface such as serial would be a bit different but still simple if you are already getting a barcode from it.
Re: Barcode scanner with C#
Quote:
Originally Posted by
BioPhysEngr
barcode addict: Actually it's more probable that you will get replies faster if you start new threads.
The laziest possible thing you could do would be to just have the method that populates the textbox call the button's click event handler method (e.g. Button_Click(...)). Alternatively, you could just put the button click code on the end of the barcode scanner's event handler. If the barcode is read in character-by-character, you might need to do some sort of checking or validation to see when the complete code has been read.
Simple enough?
Thank you so so much! I will instantly give it a shot and check whether my client is satisfied. Really, thanks a lot!
Re: Barcode scanner with C#
Quote:
Originally Posted by
barcode addict
sorry, as my project is due this friday, so I have no time to start a new discussion and wait for others to find that new thread. Here is my problem
I am working on a project that updates the records in my database from a barcode scanner, at the moment when you scan an item it places the
barcode created ina textbox on my form. Which needs a button click to submit the record to the database. and I am trying to achieve this: once the item has been scanned for the record to be inserted into the database without having to manually clicking a button.
So please give me some feasible advice, thank you so much.
Actually your method can be used to count how many products have been scanned.:lol:
Re: Barcode scanner with C#
keydown or the keypress event is the best way to deal with it and simple, easy. Its also in the TextChanged method - check for the format you need for it to be a barcode and then do processing. Thats how it has to be done. There must be free barcode libs as wellt hat let you do more.
--
BossMode - http://bossware.blogspot.com/