Code:
Private Sub Command1_Click()
On Error Goto Yer_Aving_A_Laugh
FileCopy "C:\AFile.exe", "A:\AFile.exe"
Yer_Aving_A_Laugh :
If Err.Number = 71 then
MsgBox "Disk not ready error shown - place a blloming disk in then !!!"
End Sub
End If
End Sub
Take a look at the search option for the forumns to look up "error handling".
The error you get above has the error number as 71. You might run into other problems you might want to test for on this :
- Is the disk write protected ?
- Is the disk full
For the moment, use the above with :
Code:
Yer_Aving_A_Laugh :
Msgbox "Error number is : " & err.number & VBCrlf & _
"Description : " & err.description
'This one will return a messagebox of the error number & description,
'rather than crash your app, it just exits the SUB (procedure). ;)
For your testing. Once you're happy that you've covered every angle (and you always miss some
)
You put all the errrors into one big select case statement so your app can't possibly crash....[can it?]
Code:
Yer_Aving_A_Laugh :
Select Case err.number
'check the number of the error...
Case 0
'Do something to encounter it...
Case 1
'Do something else...
Case 2
'Do something else...
End Select