Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Past End

Status
Not open for further replies.

RSH

Technical User
Jun 15, 2000
55
US
I needed to get rid of the (Input past end) error which of course crashed the program. I chose to use an error trap
like in basic for mac some years back, (ON ERROR GOTO). Is there a problem doing it this way? All my VB traps still work, and it gets rid of the annoying past end problem. One
however cannot use (RESUME) or one winds up in a loop.
73 RSH
 
Assuming the error occurs while trying to read lines from a file you should test for the End-Of-File condition after each read:
[tt]
Open "MyFile.Txt" for Input as #1
Do While Not Eof(#1)
[tab]Input #1, A$
Loop
Close #1
[/tt]

The Do Loop terminates when it detects the end of the file.
 
Anyway, Error trapping should work. You are right when using On Error Resume statement. It resumes with running the code that generates error again. So you should use On Error Resume Next instead of it.
 
If you are reading comma delimited files, it is possible that one of the fields has a comma in it or a qoute (") in a string field. In order to prevent this, you may want to use line input instead of just input.
 
Thanks All Three:
We have printed this out for future use. The reason we went the error trap route was trouble making EOF work. Will take a second look. 73 RSH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top