End Of File error (1 Viewer)

Darrell

Registered User.
Local time
Today, 20:45
Joined
Feb 1, 2001
Messages
196
Hey Guys - I have a wee problem while trying to import a text file in that I get the Run-time error '62' Input past end of file error.

Now I know what is causing this but not how to fix it.....(I'm smart enough to know how dumb I am :rolleyes: )

Basically, the text file is comprised of two rows for one record, and the second row is sometimes blank. I am using the "Line Input #1, MyLine" to go down to the second line and read it but, at the end of the file, if this second row is blank, I get the error when the "Line Input #1, MyLine" code tries to run.

What I need is to be able to see if this next line is blank and therefore skip trying to read it.

Any ideas greatly appreciated.

Cheers
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 20:45
Joined
Sep 12, 2006
Messages
13,892
presumably a blank line has a crlf at the end

why not read two rows at a time

ie lineinput #1, myline1
ie lineinput #1, myline2

then you can test the second line, with if myline2=vbnullstring etc and react accordingly.
 

Bodisathva

Registered User.
Local time
Today, 15:45
Joined
Oct 4, 2005
Messages
1,274
While Not (FileName.EOF)

or

If NOT (FileName.EOF)
 

Darrell

Registered User.
Local time
Today, 20:45
Joined
Feb 1, 2001
Messages
196
gemma - thanks for your reply, but I'm not sure what you mean by crlf or how to test for the second line.

At present it is sort of like this...

Do While Not EOF(1)
Line Input #1, MyLine
Do something
Line Input #1, MyLine
Do something else
Loop

So it's this second "Line Input #1, MyLine" where it goes kaput and is where I would like to test to see if the last line is there or not. Problem is I have absolutly no idea how to write this test or where to put it.... :confused:

I hope this makes more sense
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 20:45
Joined
Sep 12, 2006
Messages
13,892
what i meant was, if you have exactly two rows for every record, even if the second row is blank, then you don't have a problem

at the end of every row, there is actually a carriage return/line feed to get to the next row (which is how the line input knows it has reached a lnie end!

Hence, you can read rows in pairs

Do While Not EOF(1)
Line Input #1, MyLine1
Line Input #1, MyLine2

now you can say if len(myline2) = 0 then etc.
Do something
Loop

its onlya problem if there ARENT pairs of rows!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom