Android Question Barcode Scanning - detecting scan complete

cwt

Active Member
Licensed User
Longtime User
I have an app where the user can use a barcode scanner to put data in an B4XFloatTextField control.

The B4XFloatTextField control is labeled Part_Number.

To determine when the barcode scan has completed, I use the code below:

B4X:
Sub Part_Number_TextChanged (Old As String, New As String)
    
    Dim ThisPart As String = New.ToUpperCase
    
    If ThisPart.EndsWith( "####" ) = True Then
    
        Dim StringLen As Int = ThisPart.IndexOf( "####" )
        Part_Number.Text = ThisPart.SubString2(0,StringLen).Trim
        
        AddItem

    End If
    
End Sub

The user must program the barcode scanner to have a suffix of #### - four pound characters. Then my code detects the suffix to accept the entry.

This is kind of cumbersome. Does anyone have a better way to determine when a barcode scan has completed?
 

cwt

Active Member
Licensed User
Longtime User
I had tried using a tab keystroke, Chr(9), but it does not appear to work.

If I remember correctly, I could not make MyString.EndsWith( Chr(9) ) or MyString.EndsWith( "Chr(9)" ) work.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
"Chr(9)" is a string not a control character.
What type of barcode are you using, what is the encoding rule for Part_Number, and what is the model and manufacturer of the scanner?
 
Upvote 0
Top