' Donc la fonction de recherche de l'élève est la première à appeller ' Il ne faut introduire aucune InputBox ou Msgbox dans ce code Public Function rechercheleve(c as String, p as String, n as String) as Integer ... Dim ixretour as Integer ixretour=-1 ... ' boucle de recherche du nom-prenom-classe dans la liste ' renvoi de l'index i en cas de succes sinon -1 If TablE(i).Nom = c and TablE(i).Prenom and TablE(i).Classe=n Then ixretour=i End if rechercheleve = ixretour End Function
Dim ixeleve as Integer Dim nom as String Dim prenom as String Dim niveau as String ' procéder à la saisie des 3 chaines caractérisant l'élève ... ' puis appeler la fonction de recherche ixeleve = rechercheleve(nom, prenom, niveau) If ixeleve = -1 then Msgbox "Elève introuvable",,"Rapport" Else Effaceeleve(ixeleve) Msgbox "Elève effacé",,"Rapport" End If ' La fonction effaceeleve vient du code Sub SuppressionE() purgé de tout message et recherche car double emploi
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionTablE(1).Nom = "Aupay" TablE(1).Prenom = "Alice" TablE(1).Classe = "ST1" TablE(1).DateN = "24/03/1994" TablE(1).S1 = -1 TablE(1).S1 = -1
Function selectionEleve(ByVal c As String, ByVal titre As String) As Integer Dim i As Integer Dim tab_I(1 To Max) As Integer Dim cpt As Integer Dim res As Integer Dim txt As String Dim Chx As Variant res = 0 cpt = 0 txt = "Selectionner l'élève " & titre & vbcr For i = 1 To NbE If TablE(i).Classe = c Then cpt = cpt + 1 txt = txt & cpt & " : " & TablE(i).Nom & " " & TablE(i).Prenom & vbcr tab_I(cpt) = i End If Next i txt = txt & 0 & " : " & "Annuler" If cpt > 0 Then Chx = InputBox(txt, "Selection", 0) Do While (Chx < 0 Or Chx > cpt) And Chx <> "" Chx = InputBox(txt, "Selection", 0) Loop If Chx <> 0 And Chx <> "" Then res = tab_I(Chx) End If End If selectionEleve = res End Function
J'ai donc puisé le code de mon professeur
C'est bien ce que je dis j'y comprends pas grand chose
Function selectionClasse(ByVal titre As String) As Integer Dim i As Integer Dim tab_I(1 To Max) As Integer Dim cpt As Integer Dim res As Integer Dim txt As String Dim Chx As Variant res = 0 cpt = 0 txt = "Selectionner la classe " & titre & vbcr For i = 1 To NbC cpt = cpt + 1 txt = txt & cpt & " : " & TablC(i) & vbcr tab_I(cpt) = i Next i txt = txt & 0 & " : " & "Annuler" 'derniere ligne If cpt > 0 Then Chx = InputBox(txt, "Selection", 0) Do While (Chx < 0 Or Chx > cpt) And Chx <> "" Chx = InputBox(txt, "Selection", 0) Loop If Chx <> 0 And Chx <> "" Then res = tab_I(Chx) End If End If selectionClasse = res End Function
Ca sera plus simple et logique si je passe par le SelectionEleve SupprimerEleve