Results 1 to 5 of 5

Thread: Error "53"

  1. #1

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Hello World
    I'm not that good at errorhandling yet,
    but why doesn't this work?
    I call this sub att form load.
    I get "Error 53 file doesn't exist" all the time and that is correct because the file doesn't exist yet.
    The user have to run the program once to create the file. should I create the file at form load or something to prevent this.

    Code:
    Private Sub ReadFromFile()
        Dim strTemp As String
        Dim strX As String
         On Error GoTo ErrorHandling
        Open App.Path & "\Recent.txt" For Input As #1
           Do While strTemp <> "[END]"
                Line Input #1, strTemp  
                If strTemp <> "[END]" Then cboSentMessages.AddItem strTemp
            Loop
        Close #1
        Exit Sub
    ErrorHandling:
    
    End Sub


    ------------------
    On Error Goto Bed
    [email protected]



  2. #2
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    Code:
    ErrorHandling:
    if err.number = 53 then
    msgbox "No File, No Fun..."
    resume next
    end if
    [This message has been edited by Inhumanoid (edited 11-26-1999).]

    [This message has been edited by Inhumanoid (edited 11-26-1999).]

  3. #3

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Thank you Inhumanoid
    But the problem is still there.
    I've tried to put the error handling in the calling routine but that doesn't work either
    I call this sub from form_load so I think I will make a check if the file exists and f it doesn't then I will create it. Not the smotthest way but it will generate no error for me (I hope)

    ------------------
    On Error Goto Bed
    [email protected]




    [This message has been edited by onerrorgoto (edited 11-29-1999).]

  4. #4
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    I just ran this on my machine:

    Code:
    Private Sub Form_Load()
        Call ReadFromFile
    End Sub
    
    Private Sub ReadFromFile()
        Dim strTemp As String
        Dim strX As String
         On Error GoTo ErrorHandling
        Open App.Path & "\Recent.txt" For Input As #1
           Do While strTemp <> "[END]"
                Line Input #1, strTemp
                If strTemp <> "[END]" Then cboSentMessages.AddItem strTemp
            Loop
        Close #1
        Exit Sub
    ErrorHandling:
    If Err.Number = 53 Then
    MsgBox "No File, No Fun..."
    Resume Next
    End If
    
    End Sub
    It worked fine (also when I compiled it)...

    Goto Tools-options (in the menubar).. Go to tabstrip general. Take a look at the frame "Error trapping" and make sure it is NOT set on "Break on all errors"...
    It should work, now...

    B.T.W. If you get the code to work now (without vb giving you some run-time error crap), it might be an idea to put code that generates the file in the errorhandler

    [This message has been edited by Inhumanoid (edited 11-29-1999).]

  5. #5

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Thank you
    Of course the option was set to "break on all errors"!!
    Sometimes the answer is to close to see.
    Thank you again

    ------------------
    On Error Goto Bed :0)[email protected]


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