Here's my sample code:
It just parses text files, that are partially fixed length, and partially not. I'm sure it's clunky, but it works, except for the fact that it still attempts to read past the end of the file, throwing an error. The EOF/loop isn't catching it for some reason. Is there an apparent reason why? Does EOF not work right when I go inside the If/then's?
________
Remember, you're unique... just like everyone else.
Code:
Open myfile For Input As #1
Do Until EOF(1)
DoEvents
operation:
Line Input #1, Linebuffer
If Left(Linebuffer, 9) = "OPERATION" Then
Line Input #1, Linebuffer
operation = Left$(Linebuffer, 15)
GoTo part:
Else
GoTo operation:
End If
part:
Line Input #1, Linebuffer
If Left$(Linebuffer, 4) = "PART" Then
Line Input #1, Linebuffer
part = Left$(Linebuffer, 8)
GoTo readings:
Else
GoTo part:
End If
readings:
Dim found1 As Integer
Line Input #1, Linebuffer
If Left$(Linebuffer, 4) = "0000" Then
Fieldname = Mid$(Linebuffer, 6, 15)
reading = Mid$(Linebuffer, 74, 7)
txtDisplay.Text = txtDisplay.Text & Trim$(operation) & ", " & Trim$(part) & ", " & Trim$(Fieldname) & ", " & _
Trim$(reading) & Chr(13)
found1 = found1 + 1
GoTo readings:
Else
If found1 = 0 Then
GoTo readings
End If
End If
Loop
It just parses text files, that are partially fixed length, and partially not. I'm sure it's clunky, but it works, except for the fact that it still attempts to read past the end of the file, throwing an error. The EOF/loop isn't catching it for some reason. Is there an apparent reason why? Does EOF not work right when I go inside the If/then's?
________
Remember, you're unique... just like everyone else.