Boucle ou fonction

Bonjour le forum

Je souhaite compiler ce code au plus simple par une fonction au une boucle

Voici le code

Private Sub ChckB_1_AfterUpdate()
    If IsNull(ChckB_1.Value) Then: TextBox1.Visible = True
End Sub
Private Sub ChckB_1_Click(): TextBox1.Visible = ChckB_1.Value: End Sub
Private Sub ChckB_2_AfterUpdate()
    If IsNull(ChckB_2.Value) Then: TextBox2.Visible = True
End Sub
Private Sub ChckB_2_Click(): TextBox2.Visible = ChckB_2.Value: End Sub
Private Sub ChckB_3_AfterUpdate()
    If IsNull(ChckB_3.Value) Then: TextBox3.Visible = True
End Sub
Private Sub ChckB_3_Click(): TextBox3.Visible = ChckB_3.Value: End Sub
Private Sub ChckB_4_AfterUpdate()
    If IsNull(ChckB_4.Value) Then: TextBox4.Visible = True
End Sub
Private Sub ChckB_4_Click(): TextBox4.Visible = ChckB_4.Value: End Sub
Private Sub ChckB_5_AfterUpdate()
    If IsNull(ChckB_5.Value) Then: TextBox5.Visible = True
End Sub
Private Sub ChckB_5_Click(): TextBox5.Visible = ChckB_5.Value: End Sub
Private Sub ChckB_6_AfterUpdate()
    If IsNull(ChckB_6.Value) Then: TextBox6.Visible = True
End Sub
Private Sub ChckB_6_Click(): TextBox6.Visible = ChckB_6.Value: End Sub
Private Sub ChckB_7_AfterUpdate()
    If IsNull(ChckB_7.Value) Then: TextBox7.Visible = True
End Sub
Private Sub ChckB_7_Click(): TextBox7.Visible = ChckB_7.Value: End Sub
Private Sub ChckB_8_AfterUpdate()
    If IsNull(ChckB_8.Value) Then: TextBox8.Visible = True
End Sub
Private Sub ChckB_8_Click(): TextBox8.Visible = ChckB_8.Value: End Sub
Private Sub ChckB_9_AfterUpdate()
    If IsNull(ChckB_9.Value) Then: TextBox9.Visible = True
End Sub
Private Sub ChckB_9_Click(): TextBox9.Visible = ChckB_9.Value: End Sub
Private Sub ChckB_10_AfterUpdate()
    If IsNull(ChckB_10.Value) Then: TextBox10.Visible = True
End Sub
Private Sub ChckB_10_Click(): TextBox10.Visible = ChckB_10.Value: End Sub
Private Sub ChckB_11_AfterUpdate()
    If IsNull(ChckB_11.Value) Then: TextBox11.Visible = True
End Sub
Private Sub ChckB_11_Click(): TextBox11.Visible = ChckB_11.Value: End Sub
Private Sub ChckB_12_AfterUpdate()
    If IsNull(ChckB_12.Value) Then: TextBox12.Visible = True
End Sub
Private Sub ChckB_12_Click(): TextBox12.Visible = ChckB_12.Value: End Sub
Private Sub ChckB_13_AfterUpdate()
    If IsNull(ChckB_13.Value) Then: TextBox13.Visible = True
End Sub
Private Sub ChckB_13_Click(): TextBox13.Visible = ChckB_13.Value: End Sub
Private Sub ChckB_14_AfterUpdate()
    If IsNull(ChckB_14.Value) Then: TextBox14.Visible = True
End Sub
Private Sub ChckB_14_Click(): TextBox14.Visible = ChckB_14.Value: End Sub
Private Sub ChckB_15_AfterUpdate()
    If IsNull(ChckB_15.Value) Then: TextBox15.Visible = True
End Sub
Private Sub ChckB_15_Click(): TextBox15.Visible = ChckB_15.Value: End Sub
Private Sub ChckB_16_AfterUpdate()
    If IsNull(ChckB_16.Value) Then: TextBox16.Visible = True
End Sub
Private Sub ChckB_16_Click(): TextBox16.Visible = ChckB_16.Value: End Sub
Private Sub ChckB_17_AfterUpdate()
    If IsNull(ChckB_17.Value) Then: TextBox17.Visible = True
End Sub
Private Sub ChckB_17_Click(): TextBox17.Visible = ChckB_17.Value: End Sub
Private Sub ChckB_18_AfterUpdate()
    If IsNull(ChckB_18.Value) Then: TextBox18.Visible = True
End Sub
Private Sub ChckB_18_Click(): TextBox18.Visible = ChckB_18.Value: End Sub
Private Sub ChckB_19_AfterUpdate()
    If IsNull(ChckB_19.Value) Then: TextBox19.Visible = True
End Sub
Private Sub ChckB_19_Click(): TextBox19.Visible = ChckB_19.Value: End Sub
Private Sub ChckB_20_AfterUpdate()
    If IsNull(ChckB_20.Value) Then: TextBox20.Visible = True
End Sub
Private Sub ChckB_20_Click(): TextBox20.Visible = ChckB_20.Value: End Sub
Private Sub ChckB_21_AfterUpdate()
    If IsNull(ChckB_21.Value) Then: TextBox21.Visible = True
End Sub
Private Sub ChckB_21_Click(): TextBox21.Visible = ChckB_21.Value: End Sub
Private Sub ChckB_22_AfterUpdate()
    If IsNull(ChckB_22.Value) Then: TextBox22.Visible = True
End Sub
Private Sub ChckB_22_Click(): TextBox22.Visible = ChckB_22.Value: End Sub
Private Sub ChckB_23_AfterUpdate()
    If IsNull(ChckB_23.Value) Then: TextBox23.Visible = True
End Sub
Private Sub ChckB_23_Click(): TextBox23.Visible = ChckB_23.Value: End Sub
Private Sub ChckB_24_AfterUpdate()
    If IsNull(ChckB_24.Value) Then: TextBox24.Visible = True
End Sub
Private Sub ChckB_24_Click(): TextBox24.Visible = ChckB_24.Value: End Sub
Private Sub ChckB_25_AfterUpdate()
    If IsNull(ChckB_25.Value) Then: TextBox25.Visible = True
End Sub
Private Sub ChckB_25_Click(): TextBox25.Visible = ChckB_25.Value: End Sub
Private Sub ChckB_26_AfterUpdate()
    If IsNull(ChckB_26.Value) Then: TextBox26.Visible = True
End Sub
Private Sub ChckB_26_Click(): TextBox26.Visible = ChckB_26.Value: End Sub
Private Sub ChckB_27_AfterUpdate()
    If IsNull(ChckB_27.Value) Then: TextBox27.Visible = True
End Sub
Private Sub ChckB_27_Click(): TextBox27.Visible = ChckB_27.Value: End Sub
Private Sub ChckB_28_AfterUpdate()
    If IsNull(ChckB_28.Value) Then: TextBox28.Visible = True
End Sub
Private Sub ChckB_28_Click(): TextBox28.Visible = ChckB_28.Value: End Sub
Private Sub ChckB_29_AfterUpdate()
    If IsNull(ChckB_29.Value) Then: TextBox29.Visible = True
End Sub
Private Sub ChckB_29_Click(): TextBox29.Visible = ChckB_29.Value: End Sub
Private Sub ChckB_30_AfterUpdate()
    If IsNull(ChckB_30.Value) Then: TextBox30.Visible = True
End Sub
Private Sub ChckB_30_Click(): TextBox30.Visible = ChckB_30.Value: End Sub
Private Sub ChckB_31_AfterUpdate()
    If IsNull(ChckB_31.Value) Then: TextBox31.Visible = True
End Sub
Private Sub ChckB_31_Click(): TextBox31.Visible = ChckB_31.Value: End Sub
Private Sub ChckB_32_AfterUpdate()
    If IsNull(ChckB_32.Value) Then: TextBox32.Visible = True
End Sub
Private Sub ChckB_32_Click(): TextBox32.Visible = ChckB_32.Value: End Sub
Private Sub ChckB_33_AfterUpdate()
    If IsNull(ChckB_33.Value) Then: TextBox33.Visible = True
End Sub
Private Sub ChckB_33_Click(): TextBox33.Visible = ChckB_33.Value: End Sub
Private Sub ChckB_34_AfterUpdate()
    If IsNull(ChckB_34.Value) Then: TextBox34.Visible = True
End Sub
Private Sub ChckB_34_Click(): TextBox34.Visible = ChckB_34.Value: End Sub
Private Sub ChckB_35_AfterUpdate()
    If IsNull(ChckB_35.Value) Then: TextBox35.Visible = True
End Sub
Private Sub ChckB_35_Click(): TextBox35.Visible = ChckB_35.Value: End Sub
Private Sub ChckB_36_AfterUpdate()
    If IsNull(ChckB_36.Value) Then: TextBox36.Visible = True
End Sub
Private Sub ChckB_36_Click(): TextBox36.Visible = ChckB_36.Value: End Sub
Private Sub ChckB_37_AfterUpdate()
    If IsNull(ChckB_37.Value) Then: TextBox37.Visible = True
End Sub
Private Sub ChckB_37_Click(): TextBox37.Visible = ChckB_37.Value: End Sub
Private Sub ChckB_38_AfterUpdate()
    If IsNull(ChckB_38.Value) Then: TextBox38.Visible = True
End Sub
Private Sub ChckB_38_Click(): TextBox38.Visible = ChckB_38.Value: End Sub
Private Sub ChckB_39_AfterUpdate()
    If IsNull(ChckB_39.Value) Then: TextBox39.Visible = True
End Sub
Private Sub ChckB_39_Click(): TextBox39.Visible = ChckB_39.Value: End Sub
Private Sub ChckB_40_AfterUpdate()
    If IsNull(ChckB_40.Value) Then: TextBox40.Visible = True
End Sub
Private Sub ChckB_40_Click(): TextBox40.Visible = ChckB_40.Value: End Sub
Private Sub ChckB_41_AfterUpdate()
    If IsNull(ChckB_41.Value) Then: TextBox41.Visible = True
End Sub
Private Sub ChckB_41_Click(): TextBox41.Visible = ChckB_41.Value: End Sub
Private Sub ChckB_42_AfterUpdate()
    If IsNull(ChckB_42.Value) Then: TextBox42.Visible = True
End Sub
Private Sub ChckB_42_Click(): TextBox42.Visible = ChckB_42.Value: End Sub
Private Sub ChckB_43_AfterUpdate()
    If IsNull(ChckB_43.Value) Then: TextBox43.Visible = True
End Sub
Private Sub ChckB_43_Click(): TextBox43.Visible = ChckB_43.Value: End Sub
Private Sub ChckB_44_AfterUpdate()
    If IsNull(ChckB_44.Value) Then: TextBox44.Visible = True
End Sub
Private Sub ChckB_44_Click(): TextBox44.Visible = ChckB_44.Value: End Sub
Private Sub ChckB_45_AfterUpdate()
    If IsNull(ChckB_45.Value) Then: TextBox45.Visible = True
End Sub
Private Sub ChckB_45_Click(): TextBox45.Visible = ChckB_45.Value: End Sub
Private Sub ChckB_46_AfterUpdate()
    If IsNull(ChckB_46.Value) Then: TextBox46.Visible = True
End Sub
Private Sub ChckB_46_Click(): TextBox46.Visible = ChckB_46.Value: End Sub
Private Sub ChckB_47_AfterUpdate()
    If IsNull(ChckB_47.Value) Then: TextBox47.Visible = True
End Sub
Private Sub ChckB_47_Click(): TextBox47.Visible = ChckB_47.Value: End Sub
Private Sub ChckB_48_AfterUpdate()
    If IsNull(ChckB_48.Value) Then: TextBox48.Visible = True
End Sub
Private Sub ChckB_48_Click(): TextBox48.Visible = ChckB_48.Value: End Sub
Private Sub ChckB_49_AfterUpdate()
    If IsNull(ChckB_49.Value) Then: TextBox49.Visible = True
End Sub
Private Sub ChckB_49_Click(): TextBox49.Visible = ChckB_49.Value: End Sub
Private Sub ChckB_50_AfterUpdate()
    If IsNull(ChckB_50.Value) Then: TextBox50.Visible = True
End Sub
Private Sub ChckB_50_Click(): TextBox50.Visible = ChckB_50.Value: End Sub
Private Sub ChckB_51_AfterUpdate()
    If IsNull(ChckB_51.Value) Then: TextBox51.Visible = True
End Sub
Private Sub ChckB_51_Click(): TextBox51.Visible = ChckB_51.Value: End Sub
Private Sub ChckB_52_AfterUpdate()
    If IsNull(ChckB_52.Value) Then: TextBox52.Visible = True
End Sub
Private Sub ChckB_52_Click(): TextBox52.Visible = ChckB_52.Value: End Sub
Private Sub ChckB_53_AfterUpdate()
    If IsNull(ChckB_53.Value) Then: TextBox53.Visible = True
End Sub
Private Sub ChckB_53_Click(): TextBox53.Visible = ChckB_53.Value: End Sub
Private Sub ChckB_54_AfterUpdate()
    If IsNull(ChckB_54.Value) Then: TextBox54.Visible = True
End Sub
Private Sub ChckB_54_Click(): TextBox54.Visible = ChckB_54.Value: End Sub
Private Sub ChckB_55_AfterUpdate()
    If IsNull(ChckB_55.Value) Then: TextBox55.Visible = True
End Sub
Private Sub ChckB_55_Click(): TextBox55.Visible = ChckB_55.Value: End Sub
Private Sub ChckB_56_AfterUpdate()
    If IsNull(ChckB_56.Value) Then: TextBox56.Visible = True
End Sub
Private Sub ChckB_56_Click(): TextBox56.Visible = ChckB_56.Value: End Sub
Private Sub ChckB_57_AfterUpdate()
    If IsNull(ChckB_57.Value) Then: TextBox57.Visible = True
End Sub
Private Sub ChckB_57_Click(): TextBox57.Visible = ChckB_57.Value: End Sub
Private Sub ChckB_58_AfterUpdate()
    If IsNull(ChckB_58.Value) Then: TextBox58.Visible = True
End Sub
Private Sub ChckB_58_Click(): TextBox58.Visible = ChckB_58.Value: End Sub
Private Sub ChckB_59_AfterUpdate()
    If IsNull(ChckB_59.Value) Then: TextBox59.Visible = True
End Sub
Private Sub ChckB_59_Click(): TextBox59.Visible = ChckB_59.Value: End Sub
Private Sub ChckB_60_AfterUpdate()
    If IsNull(ChckB_60.Value) Then: TextBox60.Visible = True
End Sub
Private Sub ChckB_60_Click(): TextBox60.Visible = ChckB_60.Value: End Sub
Private Sub ChckB_61_AfterUpdate()
    If IsNull(ChckB_61.Value) Then: TextBox61.Visible = True
End Sub
Private Sub ChckB_61_Click(): TextBox61.Visible = ChckB_61.Value: End Sub
Private Sub ChckB_62_AfterUpdate()
    If IsNull(ChckB_62.Value) Then: TextBox62.Visible = True
End Sub
Private Sub ChckB_62_Click(): TextBox62.Visible = ChckB_62.Value: End Sub
Private Sub ChckB_63_AfterUpdate()
    If IsNull(ChckB_63.Value) Then: TextBox63.Visible = True
End Sub
Private Sub ChckB_63_Click(): TextBox63.Visible = ChckB_63.Value: End Sub
Private Sub ChckB_64_AfterUpdate()
    If IsNull(ChckB_64.Value) Then: TextBox64.Visible = True
End Sub
Private Sub ChckB_64_Click(): TextBox64.Visible = ChckB_64.Value: End Sub
Private Sub ChckB_65_AfterUpdate()
    If IsNull(ChckB_65.Value) Then: TextBox65.Visible = True
End Sub
Private Sub ChckB_65_Click(): TextBox65.Visible = ChckB_65.Value: End Sub
Private Sub ChckB_66_AfterUpdate()
    If IsNull(ChckB_66.Value) Then: TextBox66.Visible = True
End Sub
Private Sub ChckB_66_Click(): TextBox66.Visible = ChckB_66.Value: End Sub
Private Sub ChckB_67_AfterUpdate()
    If IsNull(ChckB_67.Value) Then: TextBox67.Visible = True
End Sub
Private Sub ChckB_67_Click(): TextBox67.Visible = ChckB_67.Value: End Sub
Private Sub ChckB_68_AfterUpdate()
    If IsNull(ChckB_68.Value) Then: TextBox68.Visible = True
End Sub
Private Sub ChckB_68_Click(): TextBox68.Visible = ChckB_68.Value: End Sub

Cordialement

Bonsoir,

il faut se tourner vers les "modules de class", qui permettent de mettre en place un code "répétitif et identique" sur plusieurs contrôle.

Mais je ne maitrise pas la chose, mais le principe est le suivant : si action sur contrôle "détecter" et que cette action est "clic" alors module de class "clic_contrôle" avec en paramètre le numéro du contrôle; le module de class fait ce qu'il a à faire...

Sur le fichier j'avais réussit à adapter un truc trouvé sur le net.

Il permet au niveau du USF de gérer les coches et décoches de nombreuses boite à cocher afin de mettre à jour un graphique :

@ bientôt

LouReeD

Merci LouReeD

En téléchargeant ton fichier, je comprends moyennent mais je crois avoir compris

Voilà ce que j'en ressors

Dans un module ce classe

Public WithEvents ChckB As MSForms.CheckBox, F As Byte
Private Sub ChckB_Click()
  F = Right(ChckB.Name, Len(ChckB.Name) - 8)
  With Userform3
    .Controls("TextBox" & F).Visible = ChckB
  End With
End Sub
Dim ChckB(68) As New ClasseChckB
Private Sub UserForm_Initialize() 
    Dim F As Byte
    For F = 1 To 68
        Me("TextBox" & F).Visible = False
        Set ChckB(F).ChckB = Controls("CheckBox" & F)
    Next F

Merci encore

Cordialement

Bonsoir le troll !

Si vous ave compris moyennement mais que votre modification fonctionne, alors vous me voyez ravis !!!

Comme quoi, j'hésitais à répondre car je ne maitrise pas mais en fait faut toujours apporter un peu d'eau au moulin, c'est peut-être la goutte qui fera tourner la roue...

@ bientôt

LouReeD

Rechercher des sujets similaires à "boucle fonction"