(I'm using VS2008 with EMDK v2.9 with Fix1)
I have a form, where I declare my reader:
Private WithEvents barcodeReader As Barcode.Barcode = New Barcode.Barcode
I want it to be active only in one of the controls on the form, so I do this:
Private Sub txbAccount_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txbAccount.GotFocus
barcodeReader.EnableScanner = True
End Sub
And turn it off the same way in the Lost Focus
event of that textbox.
Here is the OnRead
sub:
Private Sub barcodeReader_OnRead(ByVal sender As Object, ByVal readerData as Symbol.Barcode.ReaderData) Handles barcodeReader.OnRead
If (readerData.HasReader) Then
Try
Dim ctrl As TextBox = Ctype(GetActiveControl(), TextBox)
If (ctrl.Name = "txbAccount") Then
ctrl.Text = readerData.Text
End If
Catch ex As Exception
MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If
End Sub
The problem is: as soon as I enable scanner in the GotFocus
event of the textbox, the OnRead
event will fire over and over (with empty data) until I actually press the scan key, scan actual data - then it stops.
I've read that maybe the Handled
property is not getting set properly, however I don't see property like that for this.