Check box bloque !

Résolu
Bonjour,

jai trois cases a cocher, je voudrais pouvoir en cocher qu'une a la fois: si une est cochee, les 2 autres ne peuvent pas etre cochees. j'ai essaye de faire qqchose comme ca mais jy connais pas grand chose, alors comme prevu, ca marche pas, quelqu'un pourrait me corriger, s'il vous plait?

If CheckBox1.ListCount = 1 Then
With CheckBox2
ComboBox2.ListCount = 0 Then
with checbBox3
ComboBox3.ListCount = 0 Then
End With
End If

If CheckBox2.ListCount = 1 Then
With CheckBox1
ComboBox2.ListCount = 0 Then
End With
with checbBox3
ComboBox3.ListCount = 0 Then
End With
End If

If CheckBox3.ListCount = 1 Then
With CheckBox1
ComboBox2.ListCount = 0 Then
end With
with checbBox2
ComboBox3.ListCount = 0 Then
End With
End If

Merci!!!!
Configuration: Windows XP Internet Explorer 6.0

12 réponses

  • Votes
  • Date
  • Date décroissante
  1. Tout faux !!!

    Je fais la tracduction:

    Si le checkBox1 est coché alors
    le checkbox2 est grisé
    Sinon
    le checkbox2 revient à sa forme initiale
    Fin Si

    Pour ton cas, ça fait:

    If CheckBox1.Value = True Then 
       CheckBox2.Enabled = False 
       CheckBox3.Enabled = False 
    Else 
       CheckBox2.Enabled = True
       CheckBox3.Enabled = True 
    End If 


    ;o)
    1. juste une petite information; faire:

      If CheckBox1.Value = True Then...

      engendre 2 cas, qui s'écrivent ainsi:

      If True = True Then...
      ou
      If False = True Then...

      Vous pouvez donc en conclure que la façon optimale d'écrire votre bout de code est:

      If CheckBox1.Value Then...
      1. If CheckBox1.Checked = True Then
        CheckBox2.Enabled And checbBox3.Enabled
        End If

        If CheckBox2.Checked = True Then
        CheckBox1.Enabled And checbBox3.Enabled
        End If

        If CheckBox3.Checked = True Then
        CheckBox1.Enabled And checbBox2.Enabled
        End If

        Voila j'ai trouve d'autres choses pour changer mon programme mais ca marche toujours pas...
        1. Voila ma version finale:

          If CheckBox1.Checked = True Then
          CheckBox2.Enabled = True
          checkbBox3.Enabled = True
          End If

          If CheckBox2.Checked = True Then
          CheckBox1.Enabled = True
          checkbBox3.Enabled = True
          End If

          If CheckBox3.Checked = True Then
          CheckBox1.Enabled = True
          checkbBox2.Enabled = True
          End If

          Mais ca marche toujours pas ! :( il ne se passe rien, ca ne grise pas mes autres check box quand j'en tick une..
          qqun sait pourquoi?
          1. Bonjour

            je ne connais pas le langage etan donnée que tu ne la pas préciser mais je vais essayé xD

            If CheckBox1.Checked = True Then
            CheckBox2.Enabled = False
            checkbBox3.Enabled =  False
            End If
            
            If CheckBox2.Checked = True Then
            CheckBox1.Enabled =  False
            checkbBox3.Enabled =  False
            End If
            
            If CheckBox3.Checked = True Then
            CheckBox1.Enabled =  False
            checkbBox2.Enabled =  False
            End If 
            
            


            a tester :)
            Bon courage
            Adns
            1. Voilà un petit exemple :

                  If CheckBox1.Value = True Then
                      CheckBox2.Enabled = False
                  Else
                      CheckBox2.Enabled = True
                  End If


              A toi de jouer maintenant ...

              ;o)
              1. Cest sur excel, du virtual basic, je vais essayer ca, merci :) je vous tiens au courant !
                1. Le Else ca veut bien dire and?
                  car j'ai fait ca, merci Polux:

                  If CheckBox1.Value = True Then
                  CheckBox2.Enabled = False
                  Else
                  CheckBox3.Enabled = False
                  End If

                  If CheckBox1.Value = False Then
                  CheckBox2.Enabled = True
                  Else
                  CheckBox3.Enabled = True
                  End If

                  1ere partie: si on coche 1 alors 2 et 3 sont bloques
                  2eme partie: si on decoche 1 alors 2 et 3 sont autorises

                  Mais c'est pas ce qu'il se produit... qqun sait pourquoi?
                  1. J'ai trouve qqchose qui marche mais je comprends pas pourquoi...

                    If CheckBox1.Value = True Then
                    CheckBox2.Enabled = False
                    Else
                    CheckBox3.Enabled = True
                    End If

                    If CheckBox1.Value = False Then
                    CheckBox2.Enabled = True
                    Else
                    CheckBox3.Enabled = False
                    End If

                    qqun sait?
                    1. Merci Polux, je t'assure que ma derniere version fonctionnait, et je comprends pas comment... mais je vais mettre la tienne qui est bcp plus logique !

                      Merci