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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Withevents Overhead

Status
Not open for further replies.

MatDavies

Programmer
Feb 22, 2001
243
GB
I am using a variable declared using withevents to monitor when a form closes, so I can then close some other forms that are essentially children of the first form.
What I would like to know is what sort of overhead is involved in using withevents? will it make much of an impact on performance?

thanks in advance

Matt
 
To unload other forms, I usually just stick the close and tidy up code in the first Forms QueryUnload event Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
The problem with that way is that the same form is used in different ways with different forms. The same child form could be opened for three or four parent forms. with out having a object variable pointing to the instance of this form how would I know which instance to close?

any suggestions are welcome.

Matt
 
A child form should be loaded and unloaded by it's parent from, with-in the parent form-class:

myMDIForm

Private mnuOpenForm1_Click()
Dim f As New Form1
f.Show
End Sub
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim f As Form
For Each f In VB.Forms
Unload f
Next f
End Sub


Form1:

Option Explicit
Private myChild As myChildForm

Private Sub Form_Load()
Set myChild = New myChildForm
Load myChild
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload myChild
Set myChild = Nothing
End Sub [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Unfortunately I am just bug fixing an existing application. I would prefer to do it the way CCLINT has suggested, but because of limitations imposed by the way the application has been written I can't. The best I can do is get a reference to the parent form due to a global variable that is set when each form opens. That is why I have done it the way I have. A major re-write is planned but until then I need a 'quick fix' that won't slow the system down too much. This is why I wanted to know what sort of overhead withevents imposes.

Thanks for your answers though.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top