I have a Zebra Handheld TC56 model. I configured Datawedge in a way that every scan I made, it displayed in my B4XFloatTextField. I follow other threads in the forum and I found that other fellows use intent. I don't want to use intent. I want to trap "carriage return" after reading a barcode in B4XFloatTextField, to execute a SELECT command for searching some data in a table.
I usually do it in C# (In Windows Mobile). Is there a way to do it in B4A?
Use the TextChanged event to capture any change and check the content. If it ends with CRLF (or similar), do your search. Here you can check any value (length, etc), too
Use the TextChanged event to capture any change and check the content. If it ends with CRLF (or similar), do your search. Here you can check any value (length, etc), too
I have tested this suggestion with the following code.
B4X:
Sub txtSearch_TextChanged (Old As String, New As String)
Dim MySize, i As Int
Dim MyChar As String
MySize = New.Length
For i= 1 To MySize
MyChar = myUtilerias.Mid(New,i,1)
If MyChar = CRLF Then
myUtilerias.myMsgBox(Activity,"Its Works!!....HERE I make t he search!","OK","","")
End If
Next
End Sub
I tested my app, with this code, with a Honeywell CK75 handheld and in a Zebra TC56 model and it doesn't works using TextChanged event and CRLF.
You would actually be better of using broadcast receiver, there should be a setting in the app designed for the scanner. I develop on barcode scanners and I always use the broadcast receiver, just capture the intent it's easy enough to do, there's no need to capture carriage return.
Sub check_barcode
Dim Code As String
Code = EditText1.Text
If Code.Length = 13 Then ' EAN13
'
' Here you may check the code against a code in a databsse
'
End If
End Sub
Sub EditText1_EnterPressed
check_barcode
End Sub