Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error while loading a form in a DLL.

Status
Not open for further replies.

ndalli

Programmer
Nov 6, 1999
76
0
0
MT
Hi,

I am including an error trapping routine in the Form_Load event of a screen which runs in a DLL. When an error is encountered the process goes directly through the routine as it should. The only problem is that after the commands found in the error handling routine are executed, it continues to load the form.

Is there a way how to stop the execution of the DLL when an error is encountered?

Many thanks in advance
 
hey,

in the error handler once it has executed your code put in...

exit sub

this will surprisingly exit the sub and should stop your other code from running

hope this helps

Sam
 
Something like this in the form's Load event
Code:
Private Sub Form_Load()

    Dim intX As Integer
    Dim intY As Integer
    
    On Error GoTo ErrTrap
    
    intX = 1 / intY
    
    Exit Sub

ErrTrap:
    MsgBox "Divide by zero error", 16, "Form2 Handler"
    Resume ExitErr

ExitErr:
    Unload Me

End Sub

If the form's error handler unloads the form, the calling proc will get an error on the Show method that the form was unloaded. You can handle this in the calling proc.

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top