Vba

Debutant.VBA Messages postés 9 Date d'inscription   Statut Membre Dernière intervention   -  
patty5046 Messages postés 46 Statut Membre -
salut le forum

en faite j'ai posé sur ma userform un bouton suivant et un autre précédent
mon souhait est qu'en cliquant sur sur le bouton suivant une fois à la dernière ligne non vide, s'affiche un message par exemple "vous êtes au dernier membre enregistré
ainsi que pour le bouton précédent

la première ligne non vide est la ligne 5 et c'est là que commence l'enregistrement.

voici le code que j'ai inscris pour ses différent bouton:

suivant:
Private [/contents/446-fichier-sub Sub] CommandButton5_Click()
If Me.ComboBox1.ListIndex < Me.ComboBox1.ListCount - 1 Then
Me.ComboBox1.ListIndex = Me.ComboBox1.ListIndex + 1
End If
End Sub


Précédent:
 Private Sub CommandButton6_Click()
If Me.ComboBox1.ListIndex < Me.ComboBox1.ListCount + 1 Then
Me.ComboBox1.ListIndex = Me.ComboBox1.ListIndex - 1
End If
End Sub


EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI

Merci d'y penser dans tes prochains messages.

1 réponse

  1. patty5046 Messages postés 46 Statut Membre 5
     
    Bonjour

    Voyez ce code :
    Private Sub CommandButton5_Click()
    If Me.ComboBox1.ListIndex < Me.ComboBox1.ListCount - 1 Then
        Me.ComboBox1.ListIndex = Me.ComboBox1.ListIndex + 1
    Else
        MsgBox "Vous êtes au dernier membre enregistré"
    End If
    End Sub
    
    Private Sub CommandButton6_Click()
    If Me.ComboBox1.ListIndex < Me.ComboBox1.ListCount + 1 Then
    If Me.ComboBox1.ListIndex = 0 Then
        MsgBox "Vous êtes au premier membre enregistré"
    End If
    Me.ComboBox1.ListIndex = Me.ComboBox1.ListIndex - 1
    End If
    End Sub
    


    Bon courage
    0