Results 1 to 4 of 4

Thread: WAHY AINT IT CAPTURING THE ERROR ;o(

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344
    If file doesnt exist its suppose to capture the error but its not! Can ya see whats wrong?

    'Load The Sequential File Combo Box
    Dim intFileNumber As Integer

    intFileNumber = FreeFile 'Get next available file number

    'Load UnCharged Rooms
    frmMain.cboRooms(0).Clear 'Clear List Before Loading
    Open App.Path & "\UnchargedRooms.Dat" For Input As #intFileNumber 'open file
    Do Until EOF(intFileNumber) 'Do until end of file
    Input #intFileNumber, strReadRecord 'Put line in string
    frmMain.cboRooms(0).AddItem strReadRecord 'add string to box
    Loop 'go to next string
    Close #intFileNumber 'Close File

    HandleErrors: 'Error-Handling routine

    Select Case Err.Number 'Select Error

    Case 53 'File Not Found
    MsgBox "One Of The Dat Files Is Missing, Program Will Now Terminate.", vbCritical, "Loading Validation" 'Give Message
    Unload Me 'Clear Me From Memory
    End 'Exit Project If File Doesnt Exist
    End Select
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2
    Addicted Member donut's Avatar
    Join Date
    Mar 2001
    Location
    London, UK
    Posts
    165
    You need to stick an 'On Error GoTo HandleErrors' at the beginning of the sub. Also, you should put 'Exit Sub' before the error handler, so that the code won't fall into it if there's no error.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    OMG

    Dude....I been busting my chopts up and down and it was over that!!! I need to get some sleep or something, geesh thanks a lot....as for the exit sub......yeah ur right, adding one now.
    -RaY
    VB .Net 2010 (Ultimate)

  4. #4
    Addicted Member donut's Avatar
    Join Date
    Mar 2001
    Location
    London, UK
    Posts
    165

    Cool

    haha, no probs

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