Read Barcode

M

Mudasir Ahmed

I Guys :
I am working on a Application to read barcodes from a scanner and
list them in a ListBox on a web page. I was wondering if any one has
done a similar job.

Currently I have attached the scanner to my PC and as I scan a barcode
it reads and puts it on a notepad or textbox.
But I need to have control over the barcode and put it in the listbox.

Any ideas or code will be really appreciated.

Thanks
 
D

Drebin

Does the barcode device send any special characters first? I don't remember
off the top of my head, but I could've sworn with a credit card scanner
(type device) - it sends like \0x10 and something else first, and then sends
it's character string..

If that's the case, you could capture an event on the form, and when you see
those codes come across - set focus to your text box. ?

Aside from that, if it's just raw characters - I might force the user a
little bit - by say forcing the window on top and forcing the textbox to be
focused until they are "Done" adding items???
 
M

Mudasir Ahmed

Hi Guys :
I am working on a Application to read barcodes from a scanner and list
them in a ListBox on a web page. I was wondering if any one has done a
similar job. Is this possible ?

Currently I have attached the scanner to my PC and as I scan a barcode
it reads and puts it on a notepad or textbox.
But I need to have control over the barcode and put it in the listbox.
In other words I want to perform some validation before putting into the
list box.
Secondly under what event can I capture the value in the texbox on the
webpage ?
The user must not tab or click on the page. He wil just keep scanning
barcodes on after the other on the page. Peep Peep Peep.

Any ideas or code will be really appreciated.

Thanks
 
F

Floyd Burger

Is the barcode reader using a keyboard wedge or serial interface? If it's
using a keyboard wedge, you need to force the form focus to an editable
control, such as a TextBox, then you can use the TextChanged event to tell
when the scanner enters a new scanned code. If it's a serial interface, you
can just monitor the serial port for the packet data coming from the device.
There are several serial components, free and commercial. I've used several
of the free ones, but I'm using TransPort from www.componentscience.com now
to read barcodes from a scanner.
 
M

Mudasir Ahmed

Hi Floyd
Thanks for the reply. I am using Keyboard Wedge. That is how its been
setup in the labs.
The TextChange event does not fire until the user navigates or sets a
new focus to other object on the form.
So I dont know how to capture the data after the user scans it.

Please help me.

Thank you
 
F

Floyd Burger

The keyboard wedge behaves just like a keyboard, when it scans something it
sends the scanned code as text, just like a regular keyboard would, to the
control that has focus. As long as your control has focus it will get a
TextChanged event when the scanner sends the data. You might be having some
focus problems, have you tried just a simple form with a TextBox and
ListBox? Something like this will show you what's happening:

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
listBox1.Items.Add( string.Format( "TextChanged \"{0}\"",
textBox1.Text ) );
}

The only thing that might be difficult is determining the end of the scan.
In my test, I got a TextChanged for each char in the scan, so you'd want to
do some validation of the data to only add the code to your list when it is
a complete code.
 
M

Mudasir Ahmed

Foyd ,

TextChanged event fires for each letter (for instance if the barcode
is 'J12394834AD' then it executes for each letter and all the letters in
the listbox.

Do you have code which just collects it into a string array and puts it
in the listbox.

Thanks
 
F

Floyd Burger

Nope, don't have any code like that. The keyboard wedge makes the scanner
insert keycodes into the standard keyboard buffers, so it behaves just like
an external keyboard (without the keys of course). The string array is the
text of the control that has the focus. As far as Windows and your
application are concerned, scanning a barcode with your wedge is exactly
like someone typing the code into the keyboard. Whichever control has focus
will receive the code.
 
T

Thomas Lutz

If your bar code scanner has a "keyboard wedge" interface then the
only way to do things would be to scan the bar codes into a textbox
and then use code in the textbox that detects the carriage return at
the end of the bar code and removes the bar code text from the textbox
and writes it to your listbox.

If you use a bar code scanner that has a RS232 output then you could
write your code so that it inputs the data from the scanner through
the RS232 port directly and then writes the data to the listbox
whenever it receives the carriage return a the end of each bar code.

Those are basically your only two options.

For more information about bar coding please visit:
www.taltech.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top