[VB.NET]listbox.List.Add()
Bonjour
Je dois lire un fichier structuré et afficher son contenu dans un listbox. C'est un exercice que je dois remettre demain. Si vous avez le temps de me répondre, tant mieux, sinon... bof! J'comprendrai.
Voici le code de ma procédure
Code:
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
|
PrivateSub btnAfficher_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnAfficher.Click, mniAfficher.Click
' Lit le fichier .dat pour affichage
' déclaration des variables
Dim laEmploye As TEmploye
Dim laObjet As System.ValueType
Dim lsNomFic AsString
Dim liFicNum AsInteger
Dim liI AsInteger
'
' Initialisation des variables
laObjet = New TEmploye
lsNomFic = "Employes.dat"
liFicNum = FreeFile()
'liI = 0
'
' Lecture et affichage
Try
FileOpen(liFicNum, lsNomFic, OpenMode.Random, , , Len(laEmploye))
lsbAffichage.BeginUpdate()
DoWhileNot EOF(liFicNum)
FileGet(liFicNum, laObjet)
laEmploye = CType(laObjet, TEmploye)
lsbAffichage.Items.Add(laEmploye.Nom & " " & _
laEmploye.Prenom & " " & _
laEmploye.Sexe & " " & _
laEmploye.SalaireAnnuel)
Loop
lsbAffichage.EndUpdate()
FileClose(liFicNum)
'lsbAffichage.Items.AddRange(New Object() {laEmploye})
Catch ex As Exception
MsgBox(ex.ToString)
EndTry
'
EndSub
|
Pourquoi ça ne foctionne pas?