UserForm in Excel 2013 Discount Textbox

93 views Asked by At

I have a problem because I want to compute a discount for my 2 textbox that will display on 3rd textbox.

 1. txtPrice
 2. txtDiscount
 3. txtTotal

but I don't know how to put like txtPrice * .txtDiscount (eg 100 * .10) for computing for the discount.

I'm using this code :

Private Sub txtDiscount_Change()

    If txtPrice.Value = "" Then Exit Sub
    If txtDiscount.Value = "" Then Exit Sub
    txtTotal.Value = CDbl(txtPrice.Value) * CDbl(txtDiscount.Value)

End Sub
1

There are 1 answers

0
spideynok On

Made a few changes on this code and it solves my problem.

Hope this will help anyone in the future.

Private Sub txtDiscount_Change()

If txtPrice.Value = "" Then Exit Sub
If txtDiscount.Value = "" Then Exit Sub
txtTotal.Value = (CDbl(txtPrice.Value)) - (CDbl(txtPrice.Value) * CDbl(txtDiscount.Value)) 

End Sub