Global error handling in VB6

We are using a VB6 front end with many forms to control a robot via a microprocessor. If power to the microprocessor goes down (or the USB cable to the microprocessor is disconnected) the program causes a fatal run-time error, code 1084: The device driver call failed. How can i handle this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you using ON Error Goto and handling your errors?

SINCOAuthor Commented:
I could do, but wouldn't this need to be placed in all forms that may be active at the time of error?
I placed this in my startup routine to check for connectivity. On error i wanted to load a custom "Reconnect USB or turn robot power on" form, but I don't know how to return from the form after this error handling. And this still doesn't trap the error after startup.
Error trapping in all your procedures is a good idea but not a requirement.
It would be a good idea to have it in the procedure that creates the error. (You do not have to place it on all forms that may be active at the time of error)
Without seeing your code, it is virtually impossible to help you out

Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

  On some of my apps that connects to an sql server i have on main form an timer. Every xx seconds it checks the connection to the database. If the server is unavailable it displays a modal form and disables all other forms. Also, i have "On Error goto" on all major functions / subs. This way if a function will execute betwen the connection check it will not crash the app.
SINCOAuthor Commented:
ok, if i use a timer on my main form to do what xess suggests, after error handling/UI with a modal form, how do i return to the code that the error was generated from? resume will not work will it?
How does your application work? You have a lot of form, and from each form the user can send diffrent commands to the robot, right? You need err handler on each form and within each function. The main timer I suggested disables everithing untill the usb cable is plugged back in. That's the way I see it.

If the user creates a queue of commands for the robot and after that the app starts sending them then you can retry sending a command until success.
> how do i return to the code that the error was generated from?

All of my procedures look like this:

Public Sub MySub
On Error Goto Error
Exit Sub
    GeneralErrors "MySub" Err.Number, Err.Description
    Resume Next
End Sub

Public Sub GeneralErrors(SubName As String, Number As Long, Description As String)

Dim Msg$, Response As String
    Msg$ = Description & " (" & Number & ")"
    Response = MsgBox("Error: " & " " & Msg$ & " in " & SubName & " module. End Program?", vbYesNo + vbCritical, "REAGENT DATABASE")
    If Response = vbYes Then
    End If
End Sub

You might want to adapt this to your use.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SINCOAuthor Commented:
YAY! Done it at last. Put all the communications in one module with error handling in there. It took me ages to realise that before resuming, the link to the microprocessor had to be reset. Thanks for all the help.
Please accept an answer if your problem has been resolved

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.