Option Explicit Option Base 0 Dim Table() As String Private Sub Form_Load() Dim Texte As String Dim Lignes() As String Dim Mots() As String Dim i As Integer Dim j As Integer Dim x As Integer Dim y As Integer Open "c:\b.txt" For Binary As #1 Texte = Space$(LOF(1)) Get #1, , Texte Close #1 Lignes = Split(Texte, vbCrLf) x UBound(Lignes): y 1 ReDim Table(x, y) For i = 0 To x - 1 Mots = Split(Lignes(i), "#") If UBound(Mots) > y Then y = UBound(Mots) ReDim Preserve Table(x, y) End If For j = 0 To UBound(Mots) - 1 Table(i + 1, j + 1) = Mots(j) Next Next End Sub
Dim Texte As String, Numfile As Integer,Mots() as string,Lignes() as string,i as long Numfile = FreeFile Open "c:\b.txt" For Input As Numfile Texte = Input(LOF(Numfile), Numfile) Close Numfile Lignes = split(text,vbcrlf) 'Eclate le fichier en ligne dans un tableau For i = 0 to ubound(lignes) ' De la 1ere ligne à la dernière mots = split(lignes(i),"#") ' Eclate la ligne en mots dans un tab Msgbox Mots(0) ' 1er mot car tableau d'indice 0 Msgbox Motss(1) ' 2eme mot car tableau d'indice 0 Next
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Command1_Click() Dim Texte As String Dim Lg As Long Dim i As Integer Dim x As Integer Dim n As Integer Dim posx As Integer Dim posy As Integer Dim dx As Integer Dim dy As Integer ' Lecture du Fichier Open "c:\b.txt" For Binary As #1 Lg LOF(1): Texte Space$(Lg) Get #1, , Texte Close #1 ' position de départ posx = Label1(1).Left posy = Label1(1).Top ' définir l'intervalle entre 2 Labels dx 100: dy 100 For i = 1 To Lg x = InStr(i, Texte, "#") If x > 0 Then n = n + 1 If n > 1 Then 'création d'un nouveau Label Load Label1(n) Label1(n).Left = posx Label1(n).Top = posy Label1(n).Visible = True End If posx = posx + Label1(1).Width + dx ' changement de Ligne tous les 5 Labels If n Mod 5 = 0 Then posx = Label1(1).Left posy = posy + Label1(1).Height + dy End If Label1(n) = Mid$(Texte, i, x - i) If Mid$(Texte, x + 1, 2) Chr$(34) & Chr$(34) Then x x + 2 If Mid$(Texte, x + 1, 2) vbCrLf Then x x + 2 i = x End If Next End Sub
Dim Texte As String, Numfile As Integer,Mots() as string,Lignes() as string,i as long Numfile = FreeFile Open "c:\b.txt" For Input As Numfile Texte = Input(LOF(Numfile), Numfile) Close Numfile Lignes = split(texte,vbcrlf) 'Eclate le fichier en ligne dans un tableau For i = 0 to ubound(lignes) ' De la 1ere ligne à la dernière mots = split(lignes(i),"#") ' Eclate la ligne en mots dans un tab label1.caption = Mots(0) ' 1er mot car tableau d'indice 0 label2.caption = Mots(1) ' 2eme mot car tableau d'indice 0 label3.caption = Mots(2) ' 3eme mot car tableau d'indice 0 label4.caption = Mots(3) ' 4eme mot car tableau d'indice 0 ' etc ... etc ... Next