When is a form loaded into mem???

Moorzee

Well-known member
Joined
May 31, 2006
Messages
92
Location
England
Programming Experience
3-5
I have a main form calling a query form. The queryForm has a variable EditForm of type form. If the user dblclicks a record an edit form is shown. There are many edit forms for different purposes one of which is frmSupplier

The code which exists is in mainForm:
VB.NET:
Expand Collapse Copy
queryForm.EditForm = frmSupplierForm
Is the form loaded into memory here??????

In the query form on the dblClick event of a datagrid:
VB.NET:
Expand Collapse Copy
EditForm.showDialog
Has the form already been loaded into memory before this call???????

Cheers.
 
Last edited by a moderator:
frmSupplierForm instance was created in memory when you created this instance (probably with code: Dim frmSupplierForm As New frmSupplier)
 
Cheer for your reply John. Prob is I have no code to create an instance of the form with new statement. on query form I have create a public variable frmEditForm of type form. Even before the queryform is shown the frmEditForm is set to type frmSupplier with statement
queryForm.EditForm = frmSupplierForm. Am I correct in thinking that once this line is executed I now have an instance of frmSupplierForm loaded in memory whether shown or not?

Cheers.
 
How strange, frmSupplierForm is just the class type here, right? So only a dynamic allocation for variable of type Form is made. Still it does Show/ShowDialog without an explicit instance. It's the end of the world as we know it. ;)
 
I think, just like in old VB6, to be "helpful", microsoft create an instance of every form that is named the same as the form type.. I presume its to help old timer VB6 guys get over the shock of having to like.. make someting before they use it :)

I've seen reference like this:

VB.NET:
Expand Collapse Copy
Sub Main
Global.frmMyForm.Show()
End Sub


no instance is made by the user, but global appears to contain an instance. Another interesting thing, is i'm sure ive seen some times in vb.net where the object hasnt acttually been created until I started to use it. I forget when this occurred though..
 
Last edited by a moderator:
Yeah, I found out this is a new feature in VS2005 called 'default instance', probably for better vb6 conversion. It works similar as to default properties, but I can't find info on how to do the exactly same with own classes (besides standard singleton/factory pattern). http://msdn2.microsoft.com/en-us/library/ms233839.aspx
 
Back
Top