1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Function ParseFile(ByVal PathFile As String, Optional ByVal Sep As String) As Collection 'Parse le fichier et retourne une collection
DoEvents
Dim myCollec As New Collection
Set ParseFile = myCollec
Dim fso As New FileSystemObject
Dim myFile As File, Ts As TextStream, Txt As String, Sp As Variant
If Not fso.FileExists(PathFile) Then Exit Function
Set myFile = fso.GetFile(PathFile)
Set Ts = myFile.OpenAsTextStream(1)
Do
If Ts.AtEndOfStream Then Exit Do
Txt = Ts.ReadLine
If Sep <> "" Then
Sp = Split(Txt, Sep)
Else
Sp = Txt
End If
myCollec.Add Sp
Loop
Set ParseFile = myCollec
End Function |
Partager