[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Run Time Error '62': Input Past End Of File

Posted on 2005-04-08
4
Medium Priority
?
193 Views
Last Modified: 2010-08-05
I am saving and reading data from a text file.  If I create the file first with Notepad, it works fine, but when I execute btnaddfav_Click and I try to read the text file again, I get error 62.  Is there something I am doing wrong?  Please help.

This is what the text file looks like:
"Carputer","www.mp3car.com",0,0
"XBOX 2 News","http://xbox2news.com/",0,0
"CNN","http://www.cnn.com/",0,0
"XBOX Scene","http://xbox-scene.com/",0,0
"CNN Test","http://www.cnn.com/",0,0

Here is the code I am using:
This adds the currunt info to the text file.
Private Sub btnaddfav_Click()
    favscrx = scrhpos
    favscry = scrvpos
    favurl = brw.LocationURL
    nicname = InputBox("Enter Name For Favorite")
    filename = App.Path & "\fav.dat"
    ifile = FreeFile
    Open filename For Append As #ifile
        Write #ifile, nicname, favurl, favscrx, favscry
    Close #ifile
    favlst.AddItem nicname
End Sub

This reads the info from the text file and populates a list box.
Private Sub btnfav_Click()
    filename = App.Path & "\fav.dat"
    ifile = FreeFile
    If favlst.Visible = True Then
        favlst.Visible = False
    Else
        favlst.Clear
        Open filename For Input As #ifile
        Do While Not EOF(ifile)
            Input #ifile, nicname, favurl, favscrx, favscry
            favlst.AddItem nicname
        Loop
        Close #ifile
        favlst.Visible = True
    End If
End Sub

This reads the info from the text file and saves it to a new file minus the line that was selected in the listbox.
Private Sub btnremfav_Click()
    Dim i As Integer
    Dim bfilename As String
    bfilename = App.Path & "\temp.dat"
    selname = favlst.Text
    filename = App.Path & "\fav.dat"
    'Remove the line from the list box
    For i = 0 To favlst.ListCount - 1
        If favlst.List(i) = selname Then
            favlst.RemoveItem i
            Exit For
        End If
    Next i
    'Create a new file with the selected line removed
    Open filename For Input As #1
    Open bfilename For Output As #2
        Do Until (EOF(1))
Start:
            Input #1, nicname, favurl, favscrx, favscry
            If nicname = selname Then
                GoTo Start
            Else
                Write #2, nicname, favurl, favscrx, favscry
            End If
        Loop
    Close #1
    Close #2
    'Delete original file and rename new file as original
    Kill filename
    Name bfilename As filename
End Sub
0
Comment
Question by:alangsk
  • 3
4 Comments
 
LVL 5

Expert Comment

by:Rubyn
ID: 13742865
Your Code is working fine....
0
 
LVL 5

Expert Comment

by:Rubyn
ID: 13742867
Tell me place where exactly you are getting the error.
0
 
LVL 5

Accepted Solution

by:
Rubyn earned 1000 total points
ID: 13742897
You just misplaced the Start, So it will not check for EOF. If the skipped line is last then Error occurs

   Open bfilename For Output As #2
        Do Until (EOF(1))
Start:

Place it before:

Start:
        Do Until (EOF(1))
0
 

Author Comment

by:alangsk
ID: 13744237
Thanks Rubyn!  That fixed the problem.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) 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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month18 days, 22 hours left to enroll

834 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