I am trying to keep the sum of two textboxes in another textbox. The problem that I have is that the two numbers can change often so I need it to update everytime a change is made to the amount in one of the textboxes. If I do a function like this I get an error after the first number is entered because there is no second number yet. What is the proper way to this so that if only one box is filled it will assume the other textbox has a zero value?
VB Code:
Private Sub txtMaterial_Leave(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles txtMaterial.Leave txtTotal.Text = TotalAmount() End Sub Private Sub txtLabor_Leave(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles txtLabor.Leave txtTotal.Text = TotalAmount() End Sub Function TotalAmount() Dim sngLabor As Single = 0 Dim sngMaterial As Single = 0 sngLabor = txtLabor.Text sngMaterial = txtMaterial.Text Return sngMaterial + sngLabor End Function




Reply With Quote