Reading a Text file Line by Line
Posted on 2005-03-15
I have seen numerous reference to this question on the site but for some reason I cant get this to work. My code is as follows...
Dim varCounter As Integer
Dim varTempStorage As String
varCounter = 0
Open "C:\Code Projects\Cooling\Data\003_7360_p1_p256.txt" For Input As #1
Do Until EOF(1)
varCounter = varCounter + 1
Line Input #1, varTempStorage
Label1.Caption = varTempStorage 'Just used to show not all lines are being read...
But label1.caption shows only one line has been read. The file should contain 19 lines of text. When I open the file in word, you can see where the carriage returns are and when I open it in Excel it splits it into 19 rows. The file itself is fairly large (73kb) and each line has hundreds and hundreds of 10 digit numbers spaced by between 5 and 9 spaces. Im not sure whether this will affect it. The data itself is generated by another computer and read off a network. Could it be that visual basic does not recognise the carriage returns (but thenexcel and word seem too....) Im at a loss, any ideas anyone????