N/APosted on - 07/14/2011
How do I take two variables and add them together with two separate text boxes and add them to and get the sum and put the output into another textbox. I want to be able to get the answer without using any buttons to compute for the sum of the two textboxes
How do I get the sum of two textboxes?
If you do not need a button to use to calculate sum, you can code that for the ‘key press’ action after you fill the second textbox. Below is a sample code for resolve your problem.
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
Dim num1, num2, tot As Double
num1 = Val(TextBox1.Text)
num2 = Val(TextBox2.Text)
tot = num1 + num2
TextBox3.Text = tot
Hope this will work.