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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculations in a text box 1

Status
Not open for further replies.

Saturn57

Programmer
Aug 30, 2007
275
0
0
CA
How would I do a calculation based on values in text box 1 and text box 2 and have it go into text box 3 and be stored in the same table as text box 1 and 2. Example I would like text box 3 = text box 1 (tb1) + text box 2(tb2) x 30
 
Create an event handler for TextChanged of TextBox1 and TextBox2
Code:
    Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
        Try
            Dim val1 As Decimal = Decimal.Parse(Me.TextBox1.Text.Trim)
            Dim val2 As Decimal = Decimal.Parse(Me.TextBox2.Text.Trim)
            Me.TextBox3.Text = val1 + val2 * 30
        Catch ex As Exception
            Me.TextBox3.Text = ""
        End Try
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top