1,105,225 Community Members

How to automatically insert data to another textbox?

Member Avatar
gd740
Newbie Poster
10 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Netcode
Veteran Poster
1,049 posts since Jun 2009
Reputation Points: 33 [?]
Q&As Helped to Solve: 86 [?]
Skill Endorsements: 8 [?]
 
0
 

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

Member Avatar
gd740
Newbie Poster
10 posts since Oct 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Netcode
Veteran Poster
1,049 posts since Jun 2009
Reputation Points: 33 [?]
Q&As Helped to Solve: 86 [?]
Skill Endorsements: 8 [?]
 
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.

Member Avatar
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 557 [?]
Q&As Helped to Solve: 489 [?]
Skill Endorsements: 21 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: