我遇到了问题,因为我想为我的2 textbox
计算折扣,该折扣会显示在第3个 textbox
上。
1. txtPrice
2. txtDiscount
3. txtTotal
但我不知道如何将txtPrice * .txtDiscount
(例如100 * .10)用于计算折扣。
我正在使用此代码:
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
答案 0 :(得分:0)
对此代码进行了一些更改,它解决了我的问题。
希望这将有助于将来的任何人。
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