I have the following loop in my simple program ...
Do
line = sr.ReadLine()
If Not line Is Nothing Then
linecount = linecount + 1
If line.Length > 0 Then
If line.Chars(0) = "*"c Then
sw.WriteLine(line)
End If
End If
End If
Loop Until line Is Nothing
It works (unless I made a mistake in removing the comments which I did
to avoid line wrap problems).
But I'd rather do something like this
Do While Not (line = sr.ReadLine) Is Nothing
linecount = linecount + 1
If line.Length > 0 Then
If line.Chars(0) = "*"c Then
sw.WriteLine(line)
End If
End If
Loop
But, given the syntax I've used above, the compiler complains about
"(line = sr.ReadLine) " saying "'Is' requires operands that have
reference types, but this operand has the value type 'Boolean'."
Is there a way to do what I am trying to do? Or another way to avoid
checking for the end of file condition twice? I am trying to avoid
use of GoTo. Also, my emphasis is on performance and simplicity, not
elegance.
Thanks, Bob