D
Doug Gifford
WROX "Beginning VB.Net" 2nd Edition
Using this code from Chapter 11 Page 472:
Do
Try
' Read a line from the file...
currentLine = myReader.ReadLine
lineCounter = lineCounter + 1
Catch e As EndOfStreamException
' Display the message...
MessageBox.Show(e.Message)
' Exit the Do loop...
Exit Do
Finally
' Concatenate the data to the strData
variable...
currentData = currentData & currentLine & vbCrLf
End Try
Loop While currentLine <> Nothing
The text file I am reading has blank lines in it.
Sample:
Line one <CrLf>
Line two <CrLf>
<CrLf>
Line Four <CrLf>
Line Five <CrLf>
Line Six <CrLf>
When the code reaches Line Four it exit the loop because
currentLine = Nothing.
I want to read all the lines (one at a time) and exit the loop
when I have reached the end of the file. I still want to read past the blank
lines.
If I use a straight loop without the "While currentLine <>
Nothing" the "Catch e As EndOfStreamException" does not catch the end of
stream exception and enters an infinite loop!
How can I read the stream, one line at at time, and process
"ALL" the lines in the file?
Using this code from Chapter 11 Page 472:
Do
Try
' Read a line from the file...
currentLine = myReader.ReadLine
lineCounter = lineCounter + 1
Catch e As EndOfStreamException
' Display the message...
MessageBox.Show(e.Message)
' Exit the Do loop...
Exit Do
Finally
' Concatenate the data to the strData
variable...
currentData = currentData & currentLine & vbCrLf
End Try
Loop While currentLine <> Nothing
The text file I am reading has blank lines in it.
Sample:
Line one <CrLf>
Line two <CrLf>
<CrLf>
Line Four <CrLf>
Line Five <CrLf>
Line Six <CrLf>
When the code reaches Line Four it exit the loop because
currentLine = Nothing.
I want to read all the lines (one at a time) and exit the loop
when I have reached the end of the file. I still want to read past the blank
lines.
If I use a straight loop without the "While currentLine <>
Nothing" the "Catch e As EndOfStreamException" does not catch the end of
stream exception and enters an infinite loop!
How can I read the stream, one line at at time, and process
"ALL" the lines in the file?