-
How about this;
[VBA]
Public Sub OpenTextFileTest()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f, s
Dim i, j, m, result
Dim myArr(0 To 14, 0 To 3) As String
i = 0: j = 0
'' Open TextFile and read one line at a time
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("C:\TEMP\DDA Report.txt", ForReading)
Do While f.AtEndOfLine <> True
s = f.readline
'' Split a line into single dimensioned array
result = Split(s, "|")
'' Dump Single array elements into multi-dimensioned
For j = 0 To 3
myArr(i, j) = result(j)
Next j
i = i + 1
Loop
f.Close
'' Testing section - dump the lot to debug
i = 0: j = 0
For i = LBound(myArr) To UBound(myArr)
For j = 0 To 3
Debug.Print i & "/" & j & vbTab & myArr(i, j)
Next j
Next i
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules