How do I ignore blank lines

W

Wendy

Hi

I am reading data in from several text files and turning it into one text
file, sometimes I get blank lines inserted into my output file. My method
doesn't work. Any ideas please?

Thanks

Wendy

Do While Not EOF(1) ' Loop until end of file.
Line Input #1, textline ' Read line into variable.
If textline = "" End If
Else
If Left(fname, 5) = "APSNL" Then
Print #2, textline ' Print to the
Scunny file
Else
Print #3, textline ' Print to the
Hull file
End If

Loop
Close #1 ' Close Input file.
Kill pafname 'deletes Input file
 
D

Dave Peterson

Untested, uncompiled:

Do While Not EOF(1) ' Loop until end of file.
Line Input #1, textline ' Read line into variable.
If textline = "" Then
'skip it
Else
If Left(fname, 5) = "APSNL" Then
Print #2, textline ' Print to the Scunny file
Else
Print #3, textline ' Print to the Hull file
End If
Loop

=====
Maybe...

if trim(textline) = "" then
'skip it

(Just in case there's a space character floating around.

I'd also do this kind of check:
If ucase(Left(fname, 5)) = "APSNL" Then
to make sure upper/lower case didn't make a difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top