Bonjour,
Pour faire de la cotation automatique j'ai créer un userform avec des checkbox,
ces checkbox renvoie une cotation dans un textbox si cochée ou non, et fait l'addition de plusieurs checkbox à chaque manipulation,
Private Sub CheckBox12_Click()
If CheckBox12 = True Then
TextBox14 = "3"
TextBox21 = CDbl(TextBox12) + CDbl(TextBox13) + CDbl(TextBox14) + CDbl(TextBox15) + CDbl(TextBox16) + CDbl(TextBox17) + CDbl(TextBox18) + CDbl(TextBox19) + CDbl(TextBox20)
Else
TextBox14 = "0"
TextBox21 = CDbl(TextBox12) + CDbl(TextBox13) + CDbl(TextBox14) + CDbl(TextBox15) + CDbl(TextBox16) + CDbl(TextBox17) + CDbl(TextBox18) + CDbl(TextBox19) + CDbl(TextBox20)
End If
End Sub
Private Sub CheckBox13_Click()
If CheckBox13 = True Then
TextBox15 = "5"
TextBox21 = CDbl(TextBox12) + CDbl(TextBox13) + CDbl(TextBox14) + CDbl(TextBox15) + CDbl(TextBox16) + CDbl(TextBox17) + CDbl(TextBox18) + CDbl(TextBox19) + CDbl(TextBox20)
Else
TextBox15 = "0"
TextBox21 = CDbl(TextBox12) + CDbl(TextBox13) + CDbl(TextBox14) + CDbl(TextBox15) + CDbl(TextBox16) + CDbl(TextBox17) + CDbl(TextBox18) + CDbl(TextBox19) + CDbl(TextBox20)
End If
End Sub
vu que beaucoup de checkbox au total je voudrais simplifier l'addition des checkbox en déclarent une seule fois l'addition textbox et réutiliser la déclaration a chaque fois
Private Sub CheckBox13_Click()
Add = CDbl(TextBox12) + CDbl(TextBox13) + CDbl(TextBox14) + CDbl(TextBox15) + CDbl(TextBox16) + CDbl(TextBox17) + CDbl(TextBox18) + CDbl(TextBox19) + CDbl(TextBox20)
If CheckBox13 = True Then
TextBox15 = "5"
TextBox21 = Add
Else
TextBox15 = "0"
TextBox21 = Add
End If
End Sub
Voici ce que j'ai essayer, mais je bloque.
comment utiliser "Add" dans plusieurs private sub sans le réécrire à chaque fois