Results 1 to 5 of 5

Thread: Trouble with "On Error GoTo" operation

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Mansfield Texas
    Posts
    36

    Angry

    Ok, I have a file listbox and and a multiline textbox and i want a text file to go into the textbox, but some of the files I click on are too big and it shows the Runtime error 62

    Input past end of file message. I wanted to be able to make it show my own error message, but it shows my error message on everything now, wether there is an error or not. here is my code:

    [code]
    Private Sub File1_Click()
    On Error GoTo Ermsg
    Open File1.Path & "\" & File1.FileName For Input As #1
    Text1.Text = Input(LOF(1), 1)
    Close #1
    Ermsg:
    On Error Resume Next
    If MsgBox("Error, Either the file you have selected is too big or is corrupted. Please select another.", vbCritical, "Error!") = vbOK Then Beep
    End Sub


    What it wrong?

    [Edited by HoSs on 05-07-2000 at 01:34 PM]
    Charlie Staton
    14 y/o
    I don't smoke, I don't drink, and I don't assosciate with pokemon.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You have to exit the sub if no error is raised.
    Code:
    Private Sub File1_Click()
       On Error GoTo Ermsg
       Open File1.Path & "\" & File1.FileName For Input As #1
       Text1.Text = Input(LOF(1), 1)
       Close #1
       Exit Sub '<-- Add this line
    Ermsg:
       On Error Resume Next
       If MsgBox("Error, Either the file you have selected is" _
        & " too big or is corrupted. Please select another.", _
        vbCritical, "Error!") = vbOK Then Beep
    End Sub
    Good luck!

  3. #3

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Mansfield Texas
    Posts
    36
    it still dosn't work. Sorry.
    Charlie Staton
    14 y/o
    I don't smoke, I don't drink, and I don't assosciate with pokemon.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Input's often pasts end, and usually for beginners. This time, it's because you're file isn't textbased, so input will search until it jumps out of the file generating this error. Now instead you should open in binary and use GET to fetch the content of the file.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Mansfield Texas
    Posts
    36
    Thanks for your help. I got it figured out now!
    Charlie Staton
    14 y/o
    I don't smoke, I don't drink, and I don't assosciate with pokemon.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width