Dim tabu As String Dim n As String Private Sub Command1_Click() Dim NomFichier As String Dim Ligne As String n = 5 tabu = String$(n, vbTab) NomFichier = "C:\...\Fichier.txt" Open NomFichier For Input As #1 While Not EOF(1) Line Input #1, Ligne Ligne = Replace(Ligne, ";", tabu) List1.AddItem Ligne Wend Close #1 End Sub Private Sub List1_Click() Dim texte As String Dim x1 As Integer Dim x2 As Integer texte = List1.List(List1.ListIndex) x1 = InStr(1, texte, tabu) + n x2 = InStr(x1, texte, tabu) Label1 = Mid$(texte, x1, x2 - x1) Label2 = Mid$(texte, x2 + n) End Sub
i = InStr(1, Trame,";", vbTextCompare) If i <> 0 Then Désérialise = Left(Trame, i - 1) Trame = Right(Trame, Len(Trame) - i) End If
public nb = 1 for i = 1 to len(ligne) if mid(ligne,i,1) = ";" then select case nb case 1: nb = nb+ 1 list1.additem (left(ligne, i-1)) case 2: nb = nb+ 1 list2.additem (left(ligne, i-1)) case 3: nb = 0 ' si il n'y a que 3 arguments list3.additem (left(ligne, i-1)) next i puis ensuite tu fait un truc du genre: public sub afficher() for i = 0 to list1.listcount -1 if list1.selected(i) = true then msgbox list2.list(i) & " " & list3.list(i) end if next i end sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question' déclaration d'un type de tableau Private Type matrice_tablo nom As String detail As String autre As String End Type ' Tableau final Dim tablo() As matrice_tablo Private Sub Form_Load() Dim nFic1 As Integer Dim buf As String Dim t() As String Dim i As Integer ' On ouvre le fichier nFic1 = FreeFile Open "c:\temp\truc1\essai.txt" For Input As #nFic1 ' on le lit Do While Not EOF(nFic1) Line Input #nFic1, buf ' on splitte l'enreg dans un tableau intermédiaire t = Split(buf, ";") ' on redim le tableau pour réceptionner les valeurs ReDim Preserve tablo(i) ' on affecte les valeurs au tableau final tablo(i).nom = t(0) tablo(i).detail = t(1) tablo(i).autre = t(2) ' on se prépare à un nouvel enreg i = i + 1 Loop Close ' on remplit la listbox ou le combo. ici c une listbox mais le principe est le même For i = LBound(tablo) To UBound(tablo) List1.AddItem tablo(i).nom Next End Sub Private Sub List1_Click() Label1.Caption = tablo(List1.ListIndex).detail Label2.Caption = tablo(List1.ListIndex).autre End Sub