Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about using textboxes

Status
Not open for further replies.

kjspear

Programmer
Feb 13, 2002
173
US
Hello everyone,

I'm learning VB.NET. I created a form with a text box. I'm not sure how to capture the users data entry from the textbox to store in a variable. Here is what I used'

'
Me.TextBox3.Focus()
totalg = Val(TextBox3.Text)
Me.TextBox3.Update()'

What I want to do is when the user enters a number in the textbox and calculates that number.

Thank you in advance.
 
You will have to explain better what you want andwhat you got. ANd what the problem is.

This seems to be to simple.

Christiaan Baes
Belgium

My Blog
 
If you had 3 textboxes on your form, TextBox1, TextBox2, and TextBox3 and you wanted to add TextBox1 to TextBox2 and display in TextBox3 you could do the following.
Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
	If e.KeyCode = Keys.Enter Then
		 If Not TextBox1.Text.Trim = "" And Not TextBox1.Text.Trim = "" Then
			  If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then
					e.Handled = True
			 		e.SuppressKeyPress = True
					TextBox3.Text = CInt(TextBox1.Text) + CInt(TextBox2.Text)
			  End If
		 End If
	End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top