Detect bacode input

2007-07-10 12:15 pm
I am going to write a .NET Windows program that let users scan barcode data into a textbox. I want to fire an event upon scanning a barcode. The scanner is connected to the USB port of the computer.

My idea is to capture the event by detecting data coming from the USB port. I am not sure if this is the right way to do it. If detecting USB input is the right way, is there any .NET framework class that can do the job? If not, how to fire an event upon scanning.

回答 (1)

2007-07-14 11:09 pm
✔ 最佳答案
朋友, 不用那麼麻煩的, 其實barcode scanner所做的動作, 是等同keyboard 輸入, 然後最後鍵入"enter"而已. 即你只要handle keyboard keydown或keypress event便可, 例子如下,
Public Sub textbox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) handles textbox1.keypress
Dim strChar As String
If Asc(e.KeyChar) = 13 Then
..... do sth.
End If
End Sub
參考: me


收錄日期: 2021-04-23 21:31:11
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070710000051KK00534

檢視 Wayback Machine 備份