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

Peter Simpson

Expert
Licensed User
Longtime User
barcode scanner
Is it Bluetooth, you have not said?

I can probably send you a working example, but @ac9ts is 100% correct, using carriage return is the correct way.

I've developed enough stock control systems for clients and their warehouses to know that if they are not using dedicated hardware barcode solution like Honeywell, Zebra etc, then make sure that the end char is carriage return when Bluetooth scanning. As for example EAN8 and EAN13, ISBN-10, UPC-12 are all different lengths. The original manual should allow you to set end character, so always use carriage return, it's as simple as that.

Part_Number_TextChanged will fire an every char change,there are ways around that.

So, is it a Bluetooth barcode scanner?
 
Upvote 0
Top