Scanning barcodes (urgent)

T

tim

Hi all



I have made a application that scans barcode. The barcode scanner is connect
to the PC via one of the USB ports.



The technique that I use is hidden textbox that constantly has the focus to
process the input on the keydown event. This works fine.



It goes wrong when the user clicks for instance on one of the listboxes.
Before start scanning the user has to click on a button on the toolbar first
to set the focus back on the textbox. In some other cases I can do that in
code.



My customer has problems to click on the button first to start scanning
again. My question is if there is a other method that constantly receives
input from a barcode scanner and process it. If have tried to monitor the
USB port but I can't figure it out how this works. What also interest me is
how other programs do this.



Hopefully someone can help me with suggestions, sample or websites with
information about this topic.



Thanks in advance.

Tim





O yes, I posted this message in two newsgroups because I develop in VB6
and/or .Net so don't' shout at me please.
 
K

kimiraikkonen

Hi all

I have made a application that scans barcode. The barcode scanner is connect
to the PC via one of the USB ports.

The technique that I use is hidden textbox that constantly has the focus to
process the input on the keydown event. This works fine.

It goes wrong when the user clicks for instance on one of the listboxes.
Before start scanning the user has to click on a button on the toolbar first
to set the focus back on the textbox. In some other cases I can do that in
code.

My customer has problems to click on the button first to start scanning
again. My question is if there is a other method that constantly receives
input from a barcode scanner and process it. If have tried to monitor the
USB port but I can't figure it out how this works. What also interest me is
how other programs do this.

Hopefully someone can help me with suggestions, sample or websites with
information about this topic.

Thanks in advance.

Tim

O yes, I posted this message in two newsgroups because I develop in VB6
and/or .Net so don't' shout at me please.

Hi,
You can assign a timer control to the barcode scanning form on load,
then set a reasonable interval that queries your code will scan for
barcodes, then put the barcode scanning code in that timer1.tick
event. If you need any if-then statements set them also.

Also look at control (your textbox).lostfocus event to determine what
message or action you need to when your control loses focus. If it
doesn't work look for "enter" and "leave" events.

Hope this helps.
 
M

Mathias Wührmann

Hi Tim
I have made a application that scans barcode. The barcode scanner is connect
to the PC via one of the USB ports.
The technique that I use is hidden textbox that constantly has the focus to
process the input on the keydown event. This works fine.

you probably don't need to fiddle around with programming of the
USB-port. Just set the key preview event of the form to true and monitor
the keydown event of the form instead of using a hidden textbox. In this
case, you just need to make sure that the form has focus when scanning a
code.

If those barcodes have a checksum (like EAN8 or EAN13), I suggest you
keep the last xx chars/numbers in a variable and do a checksum
calculation on that. If its valid, you just received a full barcode.


Regards,

Mathias Wuehrmann
 
T

tim

I use lost and got focus to trigger the state of my toolbar buttons.

I don't think that a timer will help. Scanning can take place at any time.

"kimiraikkonen" <[email protected]> schreef in bericht
Hi all

I have made a application that scans barcode. The barcode scanner is
connect
to the PC via one of the USB ports.

The technique that I use is hidden textbox that constantly has the focus
to
process the input on the keydown event. This works fine.

It goes wrong when the user clicks for instance on one of the listboxes.
Before start scanning the user has to click on a button on the toolbar
first
to set the focus back on the textbox. In some other cases I can do that in
code.

My customer has problems to click on the button first to start scanning
again. My question is if there is a other method that constantly receives
input from a barcode scanner and process it. If have tried to monitor the
USB port but I can't figure it out how this works. What also interest me
is
how other programs do this.

Hopefully someone can help me with suggestions, sample or websites with
information about this topic.

Thanks in advance.

Tim

O yes, I posted this message in two newsgroups because I develop in VB6
and/or .Net so don't' shout at me please.

Hi,
You can assign a timer control to the barcode scanning form on load,
then set a reasonable interval that queries your code will scan for
barcodes, then put the barcode scanning code in that timer1.tick
event. If you need any if-then statements set them also.

Also look at control (your textbox).lostfocus event to determine what
message or action you need to when your control loses focus. If it
doesn't work look for "enter" and "leave" events.

Hope this helps.
 
D

Dick Grier

Well, perhap you can get it to work. However, IMO, industrial-strength
applications should NOT use keyboad (HID) scanners. For a few dollars more,
one with a serial interface will work flawlessly, and won't require any
coding tricks (none of which I've been able to get to work reliably).

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
G

GS

so 10 millisecond or 5 ms is enough for real time? just try and see unless
you find a better alternative
 
T

Thomas Lutz

Dick Grier is right that the serial communications approach is the
best way to go although you may not need to purchase a new scanner.
You should check with the manufacturer of your bar code scanner to see
if they have a "Virtual COM Port" driver for your scanner that you can
use instead of the "keyboard wedge" interface.
Most USB scanners come from the factory configured as a "keyboard" and
when you connect them to the USB port on a PC, Windows loads the built
in Windows USB keyboard driver and the scanner works as a second
keyboard connected to your PC. Metrologic, Handheld Products and most
other scanner manufacturers also have special "Virtual COM Port"
drivers that you can use although you may have to download the special
driver from the manufacturers web site. What you have to do is to
first install the Virtual COM port driver in your PC and then you have
to scan a special bar code in the users manual for the scanner that
will switch it from a keyboard wedge scanner to a "serial" scanner.
This basically reprograms the scanner so that when you connect it to
the USB port on your PC, the new Virtual COM port driver will load
instead of the original keyboard driver.
The driver will create a COM port that will show up in your Windows
Device Manager typically as COM4 or COM5.
You would then use serial communications code in your application to
read in the data from the scanner through the COM port.
 

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