If you buy barcode-scanners with an USB-connector, they will have keyboard-emulation. Meaning, they will send key-press-events to your application as if you entered something via keyboard. You can verify that by opening just any word-processing application and scanning a barcode. It should appear as if entered it via keyboard.
So all you would have to do is to ensure that some text-input-control has the input-focus before attempting to scan something and then process it like any text-input.
Theoretically there are ways to directly read it from the barcode-scanner so that you don't have to have that text-input-control but that would be way more advanced and, as you're saying you're a beginner to VB.NET, most probably out of your current scope. If you want to take a look at that anyway, I can serve you only with an article that does this with C#:
Using Raw Input from C# to handle multiple keyboards[
^]
Edit after comment:
I built a sample-code for you. Create a new Windows-Forms-Project, add three TextBoxes to the Form via the Designer and name them BarcodeInput1, BarcodeInput2, BarcodeInput3 and add a Label named DemoLabel. Then replace the code of Form1 (source file "Form1.vb") with the following code.
If you enter (or scan) something in TextBox 1 and then press Enter (which usually barcode scanners automatically do after scanning a barcode), the entered/scanned Text will be displayed by DemoLabel and the input focus will automatically advance to TextBox 2, then to TextBox 3 and from there again to TextBox 1.
Please note that it's just a sample. I didn't clear the entered text from the TextBoxes. The VB.NET-code is an automatic translation from C# and may contain one or two oddities (but it's working).
VB.NET
Public Class Form1
Private TextBoxOrder As New Dictionary(Of TextBox, TextBox)()
Public Sub New()
InitializeComponent()
TextBoxOrder.Add(BarcodeInput1, BarcodeInput2)
TextBoxOrder.Add(BarcodeInput2, BarcodeInput3)
TextBoxOrder.Add(BarcodeInput3, BarcodeInput1)
BarcodeInput1.Tag = 1
BarcodeInput2.Tag = 2
BarcodeInput3.Tag = 3
AddHandler BarcodeInput1.KeyDown, AddressOf BarcodeInputKeyDown
AddHandler BarcodeInput2.KeyDown, AddressOf BarcodeInputKeyDown
AddHandler BarcodeInput3.KeyDown, AddressOf BarcodeInputKeyDown
AddHandler BarcodeInput1.Leave, AddressOf BarcodeInputLeave
AddHandler BarcodeInput2.Leave, AddressOf BarcodeInputLeave
AddHandler BarcodeInput3.Leave, AddressOf BarcodeInputLeave
End Sub
Private Sub BarcodeInputKeyDown(sender As Object, e As KeyEventArgs)
If e.KeyCode = Keys.Enter AndAlso ActiveControl.[GetType]() = GetType(TextBox) Then
Dim nextTextBox As TextBox
If TextBoxOrder.TryGetValue(DirectCast(ActiveControl, TextBox), nextTextBox) Then
e.Handled = True
e.SuppressKeyPress = True
nextTextBox.Focus()
End If
End If
End Sub
Private Sub BarcodeInputLeave(sender As Object, e As EventArgs)
If sender.[GetType]() = GetType(TextBox) Then
Dim textBox As TextBox = DirectCast(sender, TextBox)
If textBox.Tag.[GetType]() = GetType(Integer) Then
BarcodeScanned(textBox.Text, CInt(textBox.Tag))
End If
End If
End Sub
Private Sub BarcodeScanned(barcode As String, order As Integer)
DemoLabel.Text = Convert.ToString(order.ToString() + ": ") & barcode
End Sub
End Class
C#
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace BarcodeTest
{
public partial class Form1 : Form
{
private Dictionary<TextBox, TextBox> TextBoxOrder = new Dictionary<TextBox, TextBox>();
public BarcodeInputForm()
{
InitializeComponent();
TextBoxOrder.Add(BarcodeInput1, BarcodeInput2);
TextBoxOrder.Add(BarcodeInput2, BarcodeInput3);
TextBoxOrder.Add(BarcodeInput3, BarcodeInput1);
BarcodeInput1.Tag = 1;
BarcodeInput2.Tag = 2;
BarcodeInput3.Tag = 3;
BarcodeInput1.KeyDown += BarcodeInputKeyDown;
BarcodeInput2.KeyDown += BarcodeInputKeyDown;
BarcodeInput3.KeyDown += BarcodeInputKeyDown;
BarcodeInput1.Leave += BarcodeInputLeave;
BarcodeInput2.Leave += BarcodeInputLeave;
BarcodeInput3.Leave += BarcodeInputLeave;
}
private void BarcodeInputKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter && ActiveControl.GetType() == typeof(TextBox))
{
TextBox nextTextBox;
if(TextBoxOrder.TryGetValue((TextBox)ActiveControl, out nextTextBox))
{
e.Handled = true;
e.SuppressKeyPress = true;
nextTextBox.Focus();
}
}
}
private void BarcodeInputLeave(object sender, EventArgs e)
{
if (sender.GetType() == typeof(TextBox))
{
TextBox textBox = (TextBox)sender;
if (textBox.Tag.GetType() == typeof(int))
{
BarcodeScanned(textBox.Text, (int)textBox.Tag);
}
}
}
private void BarcodeScanned(string barcode, int order)
{
DemoLabel.Text = order.ToString() + ": " + barcode;
}
}
}