Usually barcode scanners are connected to a serial port, either physical or virtual, or they function as a keyboard (HID).
If you select one that communicates over the serial port, you need to look into the Serialport class
The advantage of using a serial port is that it is much easier to direct your scanned data into the receiving control, such as a
, regardless of if the control has focus or not.
If the scanner emulates a keyboard, it is very easy to get started.
Just put focus to the control that should receive the scanned data and scan.
Then use the
event to process the data.
The challenge is that you need to make sure the focus is on the correct control.
If you have multiple applications running this can be a bit tricky.
There are ways around this, but it is a bit more advanced.
Refer to these articles:
Global System Hooks in .NET
Using Raw Input from C# to handle multiple keyboards
They are written for c#, but should be possible to apply to VB.net as well.