|
-
Jul 10th, 2007, 09:16 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] brute force catch all error handler?
Hi All
I have a program that uses a lowlevel hook to the keyboard.
Untill now I haven't really bothered using error handling as I try to use any errors to make changes to code instead of using a app that is able to have errors (if you know what I mean)
but with the current program I want to make sure that if there is a runtime error, the hook will be cleared so as not to mess things up on the PC.
Ive looked at some examnples and tutorials on the basics of error handling, that show a softly sfotly approach, writing handlers inrto most procedures, lots of nice errror number reporting, etc.
Is there a way to write one error handler to handle the lot and just execute one action before the program dies, without worying about all the other stuff?
EG:
vb Code:
Public Sub OnError()
Call ClearWinHook
Unload
End Sub
Ta in advance
Thanks 
-
Jul 10th, 2007, 09:22 AM
#2
Re: brute force catch all error handler?
No. If you want to have a "brute force" error handler the only way is to put something like the following in every procedure, where in your case DisplayError would be the "brute force" error handler. BTW MZTools allows you to put the code in the following in every procedure at the click of a button in each Sub and Function.
Code:
Private Sub Form_Load()
On Error GoTo ErrorRoutine
Exit Sub
ErrorRoutine:
DisplayError "Form_Load"
End Sub
-
Jul 11th, 2007, 06:02 AM
#3
Re: brute force catch all error handler?
if all you want to do is clear the hooks etc, you could just put unload me for every sub that you want to error handle, in the unload event of the form you will have all the code you want to run to clear whatever
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|