|
-
Mar 28th, 2001, 10:53 AM
#1
Thread Starter
Hyperactive Member
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)
-
Mar 28th, 2001, 10:58 AM
#2
Addicted Member
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.
-
Mar 28th, 2001, 11:10 AM
#3
Thread Starter
Hyperactive Member
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)
-
Mar 28th, 2001, 11:12 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|