|
'Place the Following Code in a Module:
Public Function ErrorHandler(iErrNum) As Integer Select Case iAction Case 5 'Invalid Procedure Call MsgBox Error(iErrNum) & " Contact Help Desk." iAction = 2 Case 7 'Out of memory MsgBox "Close all unnecessary applications." iAction = 1 Case 11 'Divide by 0 MsgBox "Zero is Not a valid value." iAction = 1 Case 48, 49, 51 'Error in loading DLL MsgBox iErrNum & " Contact Help Desk" iAction = 5 Case 57 'Device I/O error MsgBox "Insert a disk into Drive A." iAction = 1 Case 68 'Device Unavailable MsgBox "Device is unavailable _ (the device may Not exist or it is _ currently unavailable)." iAction = 4 Case 482, 483 'General Printer Error MsgBox "A general printer Error has _ occurred. Your printer may be offline." iAction = 4 Case Else MsgBox "Unrecoverable Error." iAction = 5 End Select ErrorHandler = iAction End Function 'Place the following Code in each 'Procedure/Event/Function that you wish to 'utilize this Error Handling Code: On Error Goto Errhandler 'Your Code Goes Here Exit Sub Errhandler: Dim iErrorAction As Integer iErrorAction = ErrorHandler(Err) Select Case iErrorAction Case 1 Resume Case 2 Resume Next 'Case 3 'This procedure doesn't need case 3 which 'would resume to a line. Case 4 Exit Sub Case 5 End End Select |