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

Form unloading for unknown reason 1

Status
Not open for further replies.

sarahmc22

Programmer
Nov 30, 2000
36
US
I have 3 years in VB6, but am a newbie to VB.NET. I have just begun a small app in .NET, and have created a MDI parent form with 2 child forms.

This is probably a simple thing I don't recognize since I am new to .NET. Basically my problem is this: When I successfully build and then run the app in VS, the forms load and then instantly unload and thus the program terminates.

I have a Main Sub in a Module as my startup procedure. In that sub, I create an instance of the MDI parent form (class is called fclsMain) like this:

Dim frmMain as New fclsMain()
fclsMain.Show()

I elected to do this because using the MDI form as the startup object did not allow me to refer back to it and its properties and methods from the MDI child forms. Creating an object of my MDI parent form class as above let me do this.

Why does the form instantly unload? What am I missing here? Thanks for any suggestions...
 
I suppose the simple question is this:

how do I create a main class form, and then access its properties from other forms? how can i do this while keeping this main form as the startup object for the project?
 
code on form 2:

Private form1 as new form1
public sub ReferenceStartUpForm(byref frm as form1)
form1 = frm
end sub


code on startup form(form1):

private sub OpenForm2
Dim form2 as new form2
form2.referencestartupform(me)
form2.show
end sub

what this does is when you create the second form you reference the first so you can then access its propertys. HTH
 
Thanks for the good idea. I'm still curious, though, on why I couldn't start my program from a Sub Main() wherein I create the form objects and then Show() my startup form, without it mysteriously unloading the forms.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top