Option Explicit
Private Sub CommandButton1_Click()
UserForm1.Hide
End Sub
Private Sub CommandButton2_Click()
TextBox1.Text = "": TextBox2.Text = "": TextBox3.Text = "": TextBox4.Text = "": TextBox5.Text = ""
End Sub
Private Sub TextBox1_Change(): Calculer: End Sub
Private Sub TextBox2_Change(): Calculer: End Sub
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = Asc(".") Then KeyAscii = Asc(",")
End Sub
Private Sub Calculer()
Dim HT As Double, PcRem As Double, STot As Double, TVA As Double, Total As Double
On Error Resume Next
PcRem = CDbl(TextBox1.Text) / 100: If Err Then PcRem = 0: Err.Clear
HT = CDbl(TextBox2.Text)
If Err Then TextBox3.Text = "": TextBox4.Text = "": TextBox5.Text = "": Exit Sub
STot = Int((HT - HT * PcRem) * 100 + 0.5) / 100: TVA = Int(STot * 19.6 + 0.5) / 100: Total = STot + TVA
TextBox3.Text = Format(STot, "0.00"): TextBox4.Text = Format(TVA, "0.00"): TextBox5.Text = Format(Total, "0.00")
End Sub