cs_moslem
Messages postés6Date d'inscriptionvendredi 5 mars 2004StatutMembreDernière intervention10 août 2009
-
9 juin 2008 à 21:28
cs_moslem
Messages postés6Date d'inscriptionvendredi 5 mars 2004StatutMembreDernière intervention10 août 2009
-
10 juin 2008 à 12:40
Bonjour,
J'ai un fichier texte sous la forme suivante :
=================
exp1 | exp2 | exp3
exp4 | exp5 | exp6
exp7 | exp8 | exp9
.....
=================
J'ai besoin de le stocker dans un tableau à deux dimensions. J'ai essayé le code suivant mais ça me renvoie des erreurs tout le temps :
=================
Sub LoadFactor(ByVal fichier As String)
Dim FactorLoader As New StreamReader(fichier) 'Stream pour la lecture
Dim Line, Word As String ' Variable contenant le texte de la ligne
Dim unites(i, j)
i = 0
j = 1
Word = ""
Do
i = i + 1
Line = FactorLoader.ReadLine
If FactorLoader.Peek >= 0 Then
MsgBox(Line)
For Me.k = 1 To Line.Length
If Mid(Line, k, 1) <> "|" And FactorLoader.Peek >= 0 Then
Word = Word + Mid(Line, k, 1)
Else
unites(i, j) = Word
Word = ""
j = j + 1
End If
If j > 3 Then
Exit For
End If
Next
End If
MsgBox(unites(1, 1))
Loop Until Line Is Nothing
FactorLoader.Close()
End Sub
=================
L'utilisation directe de la fonction (Mid) n'est pas possible car la longueur des expressions n'est pas constante.