且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Vb.net中的商品扫描仪Windows窗体应用程序

更新时间:2023-12-06 09:49:16

你知道你正在使用哪种设备吗?



布莱斯


通常条码扫描器连接到串口,无论是物理的还是虚拟的,或者它们都可以用作键盘(HID)。



如果您选择通过串口进行通信的那个,则需要查看 Serialport class [ ^ ]

使用串口的好处是可以更容易地将扫描数据导入接收控件,例如 TextBox ,无论如何控制是否有焦点的情况。



如果扫描仪模拟一个键这是很容易上手。

只需将焦点放在应该接收扫描数据和扫描的控件上。

然后使用 TextChanged 处理数据的事件。

挑战是你需要确保焦点在正确的控制上。

如果你有运行这个的多个应用程序可能有点棘手。



有很多方法,但它更高级。

参考这些文章:

.NET中的全局系统挂钩 [ ^ ]

使用来自C#的原始输入处理多个键盘 [ ^ ]



它们是为c#编写的,但应该可以应用于VB .net以及。


Hello,

Can anyone point me to the right direction as to how I can develope a Windows Form Applicaion in VB.Net for a goods scanner?

I wish to use a scanner to scan the item, it should probably read the bar code or price?

I have read about it being possibly developed in VB.Net on the net. But is there any specific bar code or price reader scanner that I can get together with any specific coding instruction to develope the application in VB.Net?

Please assist as I wish to develope a small application for a trade store. A single scanner will be used as it will have a single cashier.

Thanking you in advance.

do you know which device you're using?

Bryce


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 TextBox, 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 TextChanged 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.