How do I get the sum of two textboxes?

Asked By 0 points N/A Posted on -
qa-featured

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

SHARE
Best Answer by Mike01
Best Answer
Best Answer
Answered By 0 points N/A #82693

How do I get the sum of two textboxes?

qa-featured

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.

 

Answered By 0 points N/A #82694

How do I get the sum of two textboxes?

qa-featured
  • There are many ways to program your project  to get the result that you want. If you are a beginner, I hope I can be of help with a simple explanation of VB "event" to get the sum of two numbers encoded in your text boxes.
  • Since you want the sum to be shown without using a button to trigger the computation, we would use the change event on each text boxes.

 

 

Related Questions