Asked By
Shaider
0 points
N/A
Posted 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
Answered By
Mike01
0 points
N/A
#82693
How do I get the sum of two textboxes?
Hey,
-
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
   End Sub
Hope this will work.
Â