5 个解决方案
#1
其实并不需要什么专门的控件,你首先要了解扫描枪及条码的原理,打开一个记事本,然后用扫描枪扫一个条码,看到记事本中内容的变化你就会发现:每次扫描的结果就是条码的内容加上一个回车,所以你只要在窗体上放一个textbox并在其keypress事件中判断是否是写入相应代码就可以了,是不是很简单呢?我做过的。
#2
要看你是用什么通讯了:是串口还是并口呢!!!
我用过串口进行条码扫描的,MSCOMM 控件就行了,我有原代码不知道对你是否有帮助
留下你的E-MAIL
我用过串口进行条码扫描的,MSCOMM 控件就行了,我有原代码不知道对你是否有帮助
留下你的E-MAIL
#3
能给我一份吗?mzdwd@163.net
#4
cl119y@citiz.net
先谢谢啦!
先谢谢啦!
#5
Private Sub Grid_Stock_KeyPress(KeyAscii As Integer)
Dim I As Integer
Dim TmpStr As String
If Backing = False Then Exit Sub
If Backing = True And ((KeyAscii < 48 Or KeyAscii > 57) _
And KeyAscii <> 13) Then KeyAscii = 0
If KeyAscii = 13 Then
ScanID = Trim(ScanID)
If Len(ScanID) <> 16 Then
MsgBox "您输入的编码不符合要求!"
ScanID = ""
Exit Sub
End If
If AddCard Is Nothing Then
MsgBox "数据连接不存在!"
ScanID = ""
Exit Sub
End If
If AddCard.GetNumber(ScanID) = False Then
MsgBox "你输入的编码无效"
ScanID = ""
Exit Sub
End If
Grid_Stock.Rows = Grid_Stock.Rows + 1
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 0) = CStr(Grid_Stock.Rows - 2)
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 1) = ScanID
ScanID = ""
Else
If KeyAscii <> 0 Then ScanID = ScanID & Chr(KeyAscii)
lbl.Caption = ScanID & " " & CStr(Len(ScanID)) '''发布时需要屏蔽
End If
End Sub
我用了FlexGrid控件,扫描器也要设置为每读一个条码后而加一个回车.ScanID是一个窗体级变量
Dim I As Integer
Dim TmpStr As String
If Backing = False Then Exit Sub
If Backing = True And ((KeyAscii < 48 Or KeyAscii > 57) _
And KeyAscii <> 13) Then KeyAscii = 0
If KeyAscii = 13 Then
ScanID = Trim(ScanID)
If Len(ScanID) <> 16 Then
MsgBox "您输入的编码不符合要求!"
ScanID = ""
Exit Sub
End If
If AddCard Is Nothing Then
MsgBox "数据连接不存在!"
ScanID = ""
Exit Sub
End If
If AddCard.GetNumber(ScanID) = False Then
MsgBox "你输入的编码无效"
ScanID = ""
Exit Sub
End If
Grid_Stock.Rows = Grid_Stock.Rows + 1
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 0) = CStr(Grid_Stock.Rows - 2)
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 1) = ScanID
ScanID = ""
Else
If KeyAscii <> 0 Then ScanID = ScanID & Chr(KeyAscii)
lbl.Caption = ScanID & " " & CStr(Len(ScanID)) '''发布时需要屏蔽
End If
End Sub
我用了FlexGrid控件,扫描器也要设置为每读一个条码后而加一个回车.ScanID是一个窗体级变量
#1
其实并不需要什么专门的控件,你首先要了解扫描枪及条码的原理,打开一个记事本,然后用扫描枪扫一个条码,看到记事本中内容的变化你就会发现:每次扫描的结果就是条码的内容加上一个回车,所以你只要在窗体上放一个textbox并在其keypress事件中判断是否是写入相应代码就可以了,是不是很简单呢?我做过的。
#2
要看你是用什么通讯了:是串口还是并口呢!!!
我用过串口进行条码扫描的,MSCOMM 控件就行了,我有原代码不知道对你是否有帮助
留下你的E-MAIL
我用过串口进行条码扫描的,MSCOMM 控件就行了,我有原代码不知道对你是否有帮助
留下你的E-MAIL
#3
能给我一份吗?mzdwd@163.net
#4
cl119y@citiz.net
先谢谢啦!
先谢谢啦!
#5
Private Sub Grid_Stock_KeyPress(KeyAscii As Integer)
Dim I As Integer
Dim TmpStr As String
If Backing = False Then Exit Sub
If Backing = True And ((KeyAscii < 48 Or KeyAscii > 57) _
And KeyAscii <> 13) Then KeyAscii = 0
If KeyAscii = 13 Then
ScanID = Trim(ScanID)
If Len(ScanID) <> 16 Then
MsgBox "您输入的编码不符合要求!"
ScanID = ""
Exit Sub
End If
If AddCard Is Nothing Then
MsgBox "数据连接不存在!"
ScanID = ""
Exit Sub
End If
If AddCard.GetNumber(ScanID) = False Then
MsgBox "你输入的编码无效"
ScanID = ""
Exit Sub
End If
Grid_Stock.Rows = Grid_Stock.Rows + 1
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 0) = CStr(Grid_Stock.Rows - 2)
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 1) = ScanID
ScanID = ""
Else
If KeyAscii <> 0 Then ScanID = ScanID & Chr(KeyAscii)
lbl.Caption = ScanID & " " & CStr(Len(ScanID)) '''发布时需要屏蔽
End If
End Sub
我用了FlexGrid控件,扫描器也要设置为每读一个条码后而加一个回车.ScanID是一个窗体级变量
Dim I As Integer
Dim TmpStr As String
If Backing = False Then Exit Sub
If Backing = True And ((KeyAscii < 48 Or KeyAscii > 57) _
And KeyAscii <> 13) Then KeyAscii = 0
If KeyAscii = 13 Then
ScanID = Trim(ScanID)
If Len(ScanID) <> 16 Then
MsgBox "您输入的编码不符合要求!"
ScanID = ""
Exit Sub
End If
If AddCard Is Nothing Then
MsgBox "数据连接不存在!"
ScanID = ""
Exit Sub
End If
If AddCard.GetNumber(ScanID) = False Then
MsgBox "你输入的编码无效"
ScanID = ""
Exit Sub
End If
Grid_Stock.Rows = Grid_Stock.Rows + 1
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 0) = CStr(Grid_Stock.Rows - 2)
Grid_Stock.TextMatrix(Grid_Stock.Rows - 2, 1) = ScanID
ScanID = ""
Else
If KeyAscii <> 0 Then ScanID = ScanID & Chr(KeyAscii)
lbl.Caption = ScanID & " " & CStr(Len(ScanID)) '''发布时需要屏蔽
End If
End Sub
我用了FlexGrid控件,扫描器也要设置为每读一个条码后而加一个回车.ScanID是一个窗体级变量