Codage avec plusieurs OptionButon

Fermé
amram.a Messages postés 56 Date d'inscription dimanche 19 mars 2017 Statut Membre Dernière intervention 19 avril 2017 - 10 avril 2017 à 20:30
amram.a Messages postés 56 Date d'inscription dimanche 19 mars 2017 Statut Membre Dernière intervention 19 avril 2017 - 11 avril 2017 à 12:22
Bonsoir les amis

d'abord un grand merci à f894009 et ThauTheme

svp j'ai besoin de vos aides si un sujet

pour une application, j'ai un utilisateur qui m'a demandé d'ajouté quelque éléments

mais là je me retrouve pas sur mon userform3

le soucis est que j'avais 4 optionButon et maintenant j'ais ajouté 3 autres encore soit 7 Vraiment je me retrouve plus sur l'useform3


pour le nouveau voici

Cells(lig, 9) =


OptionButon1=Marié(e)
OptionButon2=Célibataire
OptionButon3=Concubinage
OptionButon4=divorcé(e)
OptionButon5=veuve


Cells(lig, 17) =


OptionButon6=Oui
OptionButon7=Non


aidez moi SVP

voilà la premier code qui avec les 4 OptionButon marchait correctement

j'ajoute qu'avec ce premier code les utilisateur disent que pour certain nom, l'image n'affiche pas

Private [/contents/446-fichier-sub Sub] ComboBox1_Change()
    Dim I As Integer
    
    'raz des TextBox et OptionButton
    For C = 1 To 21
        Me.Controls("Textbox" & C) = ""
    Next C
    For C = 1 To 4
        With Me.Controls("OptionButton" & C)
            .Value = False
            .ForeColor = vbBlack
        End With
    Next C
    '-----------------------------------------------
    ListBox1.Clear
    Var = Sheets("Base de donnée").Range("A50").End(xlUp).Row
    With Worksheets("Base de donnée")
        For I = 1 To Var
            If ComboBox1.Text = Range("B" & I).Value Then
                ListBox1.AddItem .Range("C" & I)        'nom prenom
                ListBox1.List(ListBox1.ListCount - 1, 1) = I        'ligne
            End If
        Next I
    End With
End [/contents/446-fichier-sub Sub]

Private Sub CommandButton28_Click()
ThisWorkbook.Application.Visible = False
    Unload Me
    LISTETOTALE.Show
End Sub

Private Sub ListBox1_Click()
    Dim I As Integer, lig As Long
    
    'raz des TextBox et OptionButton
    For C = 1 To 21
        Me.Controls("Textbox" & C) = ""
    Next C
    
    For C = 1 To 4
        With Me.Controls("OptionButton" & C)
            .Value = False
            .ForeColor = vbBlack
        End With
    Next C
    'recuperation ligne Infos
    lig = ListBox1.List(ListBox1.ListIndex, 1)  'ligne choix
    'remplissage Textbox
    'A   D   E   F   G   H   IO J   K   L   M   N   O   P  QO R   S   T   U    V   W   X   Y
    '1   2    3   4    5   6        7   8    9  10  11  12  13       14 15  16  17  18  19  20  21
    With Worksheets("Base de donnée")
        Ntxt = 1
        For C = 1 To 25
            If C = 21 Then
                x = x
            End If
            If C <> 2 And C <> 3 And C <> 9 And C <> 17 Then
                Me.Controls("TextBox" & Ntxt) = .Cells(lig, C)
                Ntxt = Ntxt + 1
            ElseIf C = 9 Then       'Marié/Célibataire
                If .Cells(lig, 9) = "Marié" Then
                    With OptionButton1
                        .Value = True
                        .ForeColor = vbRed
                    End With
                    With OptionButton2
                        .ForeColor = vbBlack
                    End With
                Else
                    With OptionButton2
                        .Value = True
                        .ForeColor = vbRed
                    End With
                    With OptionButton1
                        .ForeColor = vbBlack
                    End With
                End If
            ElseIf C = 17 Then      'Batisé(e): Oui/Non
                If .Cells(lig, 17) = "Oui" Then
                    With OptionButton3
                        .Value = True
                        .ForeColor = vbRed
                    End With
                    With OptionButton4
                        .ForeColor = vbBlack
                    End With
                Else
                    With OptionButton4
                        .Value = True
                        .ForeColor = vbRed
                    End With
                    With OptionButton3
                        .ForeColor = vbBlack
If Dir(ThisWorkbook.Path & "\" & "PHOTOS\" & ListBox1 & ".jpg") = "" Then
    Else
Me.Image1.Picture = [/contents/1171-vbscript-fonctions-diverses LoadPicture]("")
Me.Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & "PHOTOS\" & ListBox1 & ".jpg")

                    End If
                    End With
                End If
            End If
        Next C
    End With
End Sub

Private Sub CommandButton2_Click()
ThisWorkbook.Application.Visible = False
  Unload Me
  ACCEUIL.Show  
End Sub

Private Sub CommandButton3_Click()

ThisWorkbook.Application.Visible = False
If MsgBox("Voulez-vous quitter l'application?", vbYesNo, "Copiryght Inocent Koffi.2017-IC MEMBERS V-1.0") = vbYes Then
ThisWorkbook.Save
Unload Me
ABIENTOT.Show

End If
End Sub

Private Sub UserForm_Initialize()
    ComboBox1.Clear
    ListBox1.Clear
    ListBox1.ColumnCount = 2
    ListBox1.ColumnWidths = "30;0"

    ComboBox1.AddItem "A"
    ComboBox1.AddItem "B"
    ComboBox1.AddItem "C"
    ComboBox1.AddItem "D"
    ComboBox1.AddItem "E"
    ComboBox1.AddItem "F"
    ComboBox1.AddItem "G"
    ComboBox1.AddItem "H"
    ComboBox1.AddItem "I"
    ComboBox1.AddItem "J"
    ComboBox1.AddItem "K"
    ComboBox1.AddItem "L"
    ComboBox1.AddItem "M"
    ComboBox1.AddItem "N"
    ComboBox1.AddItem "O"
    ComboBox1.AddItem "P"
    ComboBox1.AddItem "Q"
    ComboBox1.AddItem "R"
    ComboBox1.AddItem "S"
    ComboBox1.AddItem "T"
    ComboBox1.AddItem "U"
    ComboBox1.AddItem "V"
    ComboBox1.AddItem "W"
    ComboBox1.AddItem "X"
    ComboBox1.AddItem "Y"
    ComboBox1.AddItem "Z"

End Sub


SVP j'ai bésoin de vos aides
Merci à touts

1 réponse

michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 3 303
11 avril 2017 à 10:12
amram.a = débutant vba = ????

pourquoi ?

0
amram.a Messages postés 56 Date d'inscription dimanche 19 mars 2017 Statut Membre Dernière intervention 19 avril 2017
11 avril 2017 à 12:22
Veuillez beaucoup m'excusez, mais vraiment.
j'avais un souci avec le compte amram.a ainsi j'ai créer un autre compte et après j'ai pu récupérer c'est pourquoi il existe deux compte pour moi seul mais je pense que cela ne dérange rien si quelqu'un veut m'aider

essentielle c'est d'aider si ont peut la même question n'est pas répété dans les deux compte!! selon moi, rien ne dérange .
0