>I'm used to the fox and try am trying to write something decent in Excel with VBA. I'm desperate to find a way to replace my 15 year old default errorhandling (that I copied myself from someone who 15 years ago already had written it 15 years before).
>
>Any untrapped error goes to that routine and lets me close my application gracefully. I add a message to my users "wishing them a very good day too", which I must say is received with mixed feelings at times.
>
>I get the feeling that in VBA, there is nowhere I can call such an errorhanlder via the on error handler. And if I want to get the same kind of error handling, I would have to write errorhandling in each ean every procedure/sub and function.
>
>Please tell me I've overloooked something.
>
>Kind regards,
>
>Marc
My simple error handling in Access VBA looks rather like this:
Public Sub MySub
'various dims
On Error Goto errline
'lots of code
endline:
Exit Sub
errline:
Select Case Err.Number
Case 6666 'some anticipated error
' do something or other
Resume next
Case Else
Call ErrorHandle(Err.Number, Err.Description, _
"user-friendly text indicating the sub that had the error")
Resume endline
End Select
End Sub
ErrorHandle would be your favorite generic error handler, perhaps slightly modified. Mine doesn't do much more than put up a messagebox.
I know you aren't using Access, but there is a more substantial error handler in Chapter 14 of the Access 2002 Desktop Developer's Handbook by Litwin, Getz, and Gunderloy. I wouldn't be surprised if Sybex publishes a more general MS Office book, maybe written by some of the same people, with similar material on error handling.
I haven't worked in VFP in a while, so I'm forgetting the differences.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only