Bonjour

Je voudrai afficher dans une listeBox la liste des eleve dune classe d un tableau T que j'aurai rechercher par une fonction recherche

voila l'ensemble de mon prog VB

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Option Explicit
Dim T(1 To 100) As eleve
Dim nbEleves As Integer

Private Sub Command1_Click()


Dim i, k As Integer

Dim nom As String
Dim pre As String
Dim classe As String
Dim commune As String
Dim FdF As Boolean

'initialisation des variables
i = 1
FdF = False

'Il convient d'ouvrir le fichier
Open "c:\eleve.txt" For Input As 1

'lecture du fichier par appel de la procedure LIREeleve
While FdF = False
    Call lireelves(nom, pre, classe, commune, FdF)
    'rangement des infos élémentaires dans le tableau
    T(i).nom = nom
    T(i).prenom = pre
    T(i).classe = classe
    T(i).commune = commune
    i = i + 1
Wend

nbEleves = i - 1

'fermeture du fichier
Close #1

MsgBox "terminé"

End Sub
Public Sub lireelves(ByRef a As String, ByRef b As String, ByRef c As String, ByRef d As String, ByRef x As Boolean)
Dim enr As String

'lecture du fichier séquentiel
Line Input #1, enr

'découpe de l'enregistrement et initialisation des paramétres formels
a = Mid(enr, 1, 25)
b = Mid(enr, 27, 18)
c = Mid(enr, 46, 5)
d = Mid(enr, 52, 24)
x = EOF(1)


End Sub
Public Sub rempligrille()
Dim i As Integer

'Remplissage de la grille
For i = 0 To nbEleves - 1
        G.Row = i
        G.Col = 0
        G.Text = i
        G.Col = 1
        G.Text = T(i + 1).nom
        G.Col = 2
        G.Text = T(i + 1).prenom
        G.Col = 3
        G.Text = T(i + 1).classe
        G.Col = 4
        G.Text = T(i + 1).commune
Next i

End Sub
Private Sub Command2_Click()

Dim i As Integer
' initialisation dimension de la grille
G.Rows = nbEleves
G.Cols = 5
' initialisation largeur colonne de la grille
G.ColWidth(1) = 2000
G.ColWidth(2) = 1500
G.ColWidth(3) = 2000
G.ColWidth(4) = 1500
Call rempligrille
End Sub




Public Function eleve_classe(ByVal nom As String) As String


Dim i As Integer
For i = 1 To nbEleves

    If UCase(nom) = (Mid(T(i).nom, 1, (Len(nom)))) Then
            eleve_classe = T(i).classe
            
    End If
    
Next i



End Function






Private Sub Command3_Click()


Call nom_classe.List1.AddItem(nom, prenom)
End Sub

Private Sub Command4_Click()
MsgBox eleve_classe(Text2.Text)
End Sub

Private Sub Command5_Click()
Dim i As Integer
Dim temp As eleve
Dim k As Integer
For k = nbEleves - 1 To 2 Step -1
For i = 2 To k
    If T(i).nom > T(i + 1).nom Then
        temp = T(i)
        T(i) = T(i + 1)
        T(i + 1) = temp
    End If
Next i
Next k

Call rempligrille
End Sub

Private Sub G_Click()
Dim a As String
Dim b As String
Dim i As Integer
Dim temp As eleve
Dim k As Integer

'Algorithme de tri classique
For k = nbEleves - 1 To 2 Step -1
For i = 2 To k
   'selon le numero de colonne sélectionné
    Select Case G.Col
Case 1:     a = T(i).nom
            b = T(i + 1).nom
Case 2:     a = T(i).prenom
            b = T(i + 1).prenom
Case 3:     a = T(i).classe
            b = T(i + 1).classe
Case 4:     a = T(i).commune
            b = T(i + 1).commune
    End Select

    If a > b Then
        temp = T(i)
        T(i) = T(i + 1)
        T(i + 1) = temp
    End If
Next i
Next k

Call rempligrille
End Sub




Private Sub Picture1_Click()
End
End Sub
Merci