In vb.net application I have 10 Textbox and value entered by Barcode scanner
So when one Textbox1 get the value by Barcode scanner the focus moved automatically to another Textbox2 and so on.

I have this code but its working.

Private Sub A1TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A1TextBox.TextChanged

        'If A1TextBox.Text.EndsWith(vbCrLf) Then
        'Me.SelectNextControl(A1TextBox, True, True, False, False)
        'End If
    End Sub

Recommended Answers

All 11 Replies

Unless the textbox is set to multiline it will never contain a vbCrLf.

I even put Textbox multiline and in textchanged event put the code for focus
But nothing happened

Also have a look at the tab order

@Satyam, in the IDE, break on your line 3 and 4 as shown above to see if the condition is met.

You can also try setting the focus to a particular control instead of relying on the tab order

TextBox5.Focus()

Well What I think you first need to do is that since you know your barcode try finding how many digits it has the for each textbox set its max to that value like if your barcode is 5 digits then set your text box's maxlenght to 5 then on the TextChange event insert an if statement to check if this textbox maxleght has been met or not, if the max is met then set the focus to the next textbox and so on to the end.

Maybe it has to do with the settings of your scanner.
I had that problem once.
Have a look at the scanner documentation.

Yes This is right.

I set the TextBox character limit to 7 as my barcode contains 7 characters.

I am using this code so working right now ok.

If A1TextBox.Text.Length=7 Then
A2TextBox.Focus ()
End If

Well I'm glad it worked. If your problem has been solved don't forget to mark the question as solved.

Do not post the same question on different forums while you are still getting response from the other forum just like how you did here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.