Check box bloque !

Résolu
Claire -  
 ZeuSatan -
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

  1. Polux31 Messages postés 7219 Statut Membre 1 204
     
    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
  2. ZeuSatan
     
    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
  3. Polux31 Messages postés 7219 Statut Membre 1 204
     
    Bonjour,

    CheckBox1.ListCount, tu sors d'où ?

    0
  4. Claire
     
    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...
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. Claire
     
    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?
    0
  7. adns Messages postés 1152 Statut Membre 153
     
    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
    0
  8. Polux31 Messages postés 7219 Statut Membre 1 204
     
    Voilà un petit exemple :

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


    A toi de jouer maintenant ...

    ;o)
    0
  9. Claire
     
    Cest sur excel, du virtual basic, je vais essayer ca, merci :) je vous tiens au courant !
    0
  10. Polux31 Messages postés 7219 Statut Membre 1 204
     
    Checked n'est pas une propriété d'une checkbox ....
    0
  11. Claire
     
    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?
    0
  12. Claire
     
    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?
    0
  13. Claire
     
    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
    0