I can't keep a form visible after it's calling form is disposed

cyrilgupta

Newcomer
Joined
Aug 3, 2003
Messages
11
Location
New Delhi, India
Hello,

I need some newbie help.

I want to load a form from another in VB.Net. I used to do this using Load Form in VB, and the form used to stay visible even after the form that I loaded it from was destroyed.

I have tried creating a global variable for the form, but still whenever i dispose the calling form, my new form unloads as well.

... I need to load a form from another, and keep it loaded even when the first form is destroyed...

All help will be appreciated.

Regards
CyrilGupta
 
Hi, Cyril.

Really weird... are you sure you haven't declared a module level form variable with the same name of your global variable?
 
Ok.. I found the solution.

Apparently nothing is wrong with the variable that I am declaring. It's just the difference in the way that VB and VB.Net handles things.

In VB6, I used to set the Startup form to the splash screen and start using it. After 2-3 seconds, I'd unload the splash screen and move to the main form.

Not in VB.Net. In VB.Net when you destroy the startup object (form, or sub main), the entire program thread finishes. That's why the entire program was unloading when I tried to change forms, and the same problem was present even in sub main.

The solution is this..

1. Show a form using Showdialog in Sub Main instead of show.
2. Show the splash screen before the Initializecomponents call of the main form.

Posted this just to help others who might be facing the same problem.

Cheerios
 
Back
Top