Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my vb.bet application with database access , a form I have 6 Textbox. To enter data in the textbox I am using Barcode scanner.
So when I enter the data in e.g. Textbox1 ,the focus should be changed automatically to next Textbox2 and then to 3rd and so on untill 6 textboxes. After 6th Textbox it should display the msg "The Rack Is Full" and all value should be saved automatically.

How can I get this.
I searched a lot but not able to get the clue.

I am using databinder to save the data.
This code applies to save data.

VB
Me.Validate()
Me.Samplebindingsource.EndEdit()
Me.TableAdapterManger.UpdateAll(Me.Sample_StorageDataSet)


What I have tried:

I didn't find any clue.
I tried to change the scanner.
Posted
Updated 16-Feb-17 1:56am

1 solution

What you have to do is :
- give your Textbox1 the Focus when Form loads - override the OnFormLoad-Method or use the FormLoad-Event with your own method
- if the Text in Textbox1 is changed give the Focus to Textbox2 - use the Textbox1.TextChanged-Event with your own method. In this method you can also check, if the input is valid before you switch to Textbox2
- if the Text in Textbox2 is changed give the Focus to Textbox3 - use the Textbox2.TextChanged-Event with your own method. In this method you can also check, if the input is valid before you switch to Textbox3
- and so on
- in the Textbox6_TextChanged-method you check if all inputs are correct and then save that data.
 
Share this answer
 
Comments
Member 10804809 14-Feb-17 14:23pm    
I tried this method in textbox changed event, but its not shifting to textbox2

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
Ralf Meier 14-Feb-17 14:33pm    
OK ... this is also a possible way.
Are you sure that your Text in A1Textbox really ends with CR-LF ...? Have you checked it with the Debugger ?
Not each Barcode-Scanner automaticly appends a CR-LF at the end of it's Scan-String - normally it must be set per parameter for that ...
Member 10804809 14-Feb-17 14:49pm    
The each textbox contains a no. e.g. 12345
How can i modify my code (vbCrLf)?
Member 10804809 14-Feb-17 14:58pm    
I got one hint to add Tab key at end of the scan.

How to add Tab key at the end of scan?

I went to this link: https://www.experts-exchange.com/questions/28391135/Scanned-Barcode-to-Visual-Basic-Textboxes-Change-Textbox-Focus-with-Javascript.html
Ralf Meier 14-Feb-17 15:10pm    
Slow ... slow ...
The problem is not your VB-Code. This code works like you posted it. If you remove the IF-Request then you select the next Control with the TabIndex which is greater than that one from A1Textbox.
That means that the IF-Request is not working well - this part needs a CR-LF at the end of the scanned string. And even that is a part of the functionallity of the Scanner - not from your code. So perhaps somewhere in the Settings from your scanner is the ability to add a CR or a LF or a CR-LF to the scanned string. If your Scanner doesn't support this your have another possibility : check if the text in A1Textbox has the required length - I suppose that you allways scan the same type (and content-type) of Barcode ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900