Error message : Input past end of file

Posted on 2007-09-30
Last Modified: 2010-05-03
Hello group,

I have a form which shows log file contents, sometimes when I click a button to open and view the log file it raises this error message:

   "Input past end of file  (error code 62)"

What cuases this and how should I solve it?

Question by:akohan
    LVL 8

    Accepted Solution

    Have you seen this link on Microsoft's website?
    LVL 32

    Assisted Solution

    by:Robberbaron (robr)
    you will need to check for end of file BEFORE asking for the data....

    the MS link gives the general idea.

    My process....

    Sub CkeckLog_Click()
     dim logfilename as string, ffn as integer , sLogData as string
     logfilename = "test1.log"
      '1. check if file exists
        if not exists then
            MsgBox "LogFile" & logfilename & " Not found"
            exit sub
        end if
     '2. get the data
       ffn = freefile   'get a new filehandle. avoids errors/clashes
       open logfilename for input as #ffn
           do while not eof(ffn)
              Line input #ffn, sLogdata
              'display it.
       close #ffn

    End sub

    you probably have most of this but are not checking for EOF before reading data.
    Particularly if your logfile has a header string but then not checking for each dtaa line.

    I tend to NOT use INPUT #ffm, x,y,z  because that can cause the error if not enough data is available.  I read all the line (LINE INPUT) and SPLIT it up so i can check if all data is expected.

    Author Comment


    Thanks to all.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now