Appeler une procédure

Résolu
mdeg Messages postés 28 Date d'inscription mercredi 31 mars 2010 Statut Membre Dernière intervention 29 avril 2010 - 29 avril 2010 à 10:59
mdeg Messages postés 28 Date d'inscription mercredi 31 mars 2010 Statut Membre Dernière intervention 29 avril 2010 - 29 avril 2010 à 11:22
Bonjour,

J'ai deux procédures, dans la seconde procédure, à la fin je veux faire une boucle vers la première procédure mais à partir d'une certaine ligne (le début de la procédure ne doit pas être executé).

j'ai écrit ce code
Private Sub CommandButton_Supprimer_Click()

    If ListBox_Points_Homologues.ListIndex = -1 Then
        ListBox_Points_Homologues.RemoveItem (ListBox_Points_Homologues.ListCount - 1)
    Else
        ListBox_Points_Homologues.RemoveItem (ListBox_Points_Homologues.ListIndex)
    End If

ListBox_Points_Homologues.ListIndex = -1

    If ListBox_Points_Homologues.ListCount = 0 Then
        CommandButton_Supprimer.Enabled = False
    Else
        CommandButton_Supprimer.Enabled = True
    End If
    
CommandButton_Ouvrir_Click

End Sub


Mais là la procédure commandbutton_ouvrir_click commence au début. Est ce possible de commencer à une ligne définie qui se situe plus loin dans la procédure?

Merci

2 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
29 avril 2010 à 11:14
Salut,

Non ce n'est pas possible facilement.

Mais vu le nom de ta fonction, il s'agit de l'événement click d'un bouton, donc voici ce que je te propose :
Public Sub SubEnCommun()

' mets ici le code à exécuter par un appel de procédure extérieur, par exemple :
ListBox_Points_Homologues.ListIndex = -1

    If ListBox_Points_Homologues.ListCount = 0 Then
        CommandButton_Supprimer.Enabled = False
    Else
        CommandButton_Supprimer.Enabled = True
    End If

End Sub

Public Sub CommandButton_Ouvrir_Click()

' traitement spécifique, par exemple :
If ListBox_Points_Homologues.ListIndex = -1 Then
        ListBox_Points_Homologues.RemoveItem (ListBox_Points_Homologues.ListCount - 1)
    Else
        ListBox_Points_Homologues.RemoveItem (ListBox_Points_Homologues.ListIndex)
    End If

Call SubEnCommun() ' appel des traîtements en commun

End Sub



Et du coup, au lieu d'appeler CommandButton_Ouvrir_Click, appelle la sub SubEnCommun.
______________________________________

AVANT de poster votre message, veuillez lire, comprendre, et appliquer notre réglement
3
mdeg Messages postés 28 Date d'inscription mercredi 31 mars 2010 Statut Membre Dernière intervention 29 avril 2010
29 avril 2010 à 11:22
Ah oui! Nickel! J'y avais pas pensé... super!
Merci beaucoup!
0
Rejoignez-nous