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

5 Years
Discussion Span
Last Post by Mitja Bonca

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


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.


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).

Edited by Mitja Bonca: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.