0
Private Sub txtamount_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtamount.TextChanged
    If String.IsNullOrEmpty(txtquantity.Text) OrElse String.IsNullOrEmpty(txtamount.Text) Then Exit Sub
    If Not IsNumeric(txtquantity.Text) OrElse Not IsNumeric(txtamount.Text) Then Exit Sub
    txttotal.Text = CDbl(txtquantity.Text) * CDbl(txtamount.Text)
End Sub


Private Sub txtquantity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtquantity.TextChanged
    If String.IsNullOrEmpty(txtquantity.Text) OrElse String.IsNullOrEmpty(txtamount.Text) Then Exit Sub
    If Not IsNumeric(txtquantity.Text) OrElse Not IsNumeric(txtamount.Text) Then Exit Sub
    txttotal.Text = CDbl(txtquantity.Text) * CDbl(txtamount.Text)
End Sub

Private Sub txttotal_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txttotal.TextChanged
    If Len(Trim(txtquantity.Text)) = 0 And Len(Trim(txtamount.Text)) = 0 Then
        txttotal.Text = ""
    End If
End Sub

Here's my code, the amount and quantity works fine. But everytime I delete the value of quantity and amount in textbox , the total still display the previous answer...

2
Contributors
1
Reply
6
Views
2 Years
Discussion Span
Last Post by cgeier
0

You haven't set txttotal.Text = "" or txttotal.Text = Nothingin "txtamount_TextChanged" or "txtquantity_TextChanged" if txtamount or txtquantity is null or empty.

Edited by cgeier

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.