Do Until sr.Peek = -1
...
Loop
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim sr As New StreamReader(Chemin & "\" & selection)
Do Until sr.Peek = -1
i = 1
Do Until i = 15
ligne = sr.ReadLine()
Ar(i) = ligne
i = i + 1
Loop
Loop
Do Until sr.Peek = -1ne fonctionne pas. Lorsque i arrive 15, i est réinialisé à 0 et c'est reparti jusq'à la derniere ligne du fichier. Et donc dans mon tablau ce n'est pas les bonnes données qui sont stockées.
private ar as new list(of string)
private sub ReadFile(path as string)
try
ar = System.IO.File.ReadAllLines(path).ToList
Catch ex As Exception
'en cas d'exception affiche l'erreur
MessageBox.Show(ex.Message)
End Try
end sub
dim ligne as string
ligne = ar(ar.count -1)
Dim Chaine As String
Dim Ar(15) As String
Dim ligne As String
Dim i As Integer
Dim selection As String
selection = HPRIMfile.SelectedItem
Dim sr As New StreamReader(Chemin & "\" & selection & ".txt")
'While sr.Peek <> -1
i = 1
Do Until i = 15
ligne = sr.ReadLine
Ar(i) = ligne
i = i + 1
Loop
'End While
sr.Close()
bou = UCase(Ar(2))
bii = StrConv(Ar(3), vbProperCase)
baa = Ar(7)
Dada = Ar(10)