1.11M Members

How to automatically insert data to another textbox?

 
0
 

Hi, i am still a beginner in vb.net, please help me..

My question here is when i input data to a textbox1 and then i press enter using keyboard, then another description will appear in textbox2.

For example, i have to key in a company's code: A001 into textbox1, after i press Enter using keyboard, the company's full name will appear in textbox2.

i have no idea how it will be done..please kindly help me

 
0
 

Are you saving the company data anywhere, like in a database?

 
0
 

yes, i need to save all the information entered into mysql..

 
0
 

Then first, you need a form for data collection. All data must be saved in your database so in the retrieval section, when lest say a company_ID or name is entered in a text box and the 'ENTER' key is pressed, all details(description) of the company saved in the database would be retrieved.

That's a start point. You must have a data source if you want to retrieve data.

 
0
 

You can do on a very simple way:

Private Sub textBox1_KeyDown(sender As Object, e As KeyEventArgs)
	If e.KeyCode = Keys.Enter Then
		textBox2.Text = GetData(textBox1.Text.Trim())
	End If
End Sub

Private Function GetData(str As String) As String
	Dim strReturn As String = ""
	Select Case str
		Case "A001"
			strReturn = "My 1st company name"
			Exit Select
		Case "A002"
			strReturn = "My 2nd company name"
			Exit Select
	End Select

	Return strReturn
End Function

But this is an exmple code, I dont know where you will get the data, but this is one of choices to use (using switch statement).

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: