Link to home
Start Free TrialLog in
Avatar of CThomp2005
CThomp2005

asked on

Application won't shut down

Have been working all night on a simple little program that uses 5 forms (more to be added).  Each form has buttons to open any of the others while closing itself.  Form1 is the startup Form and is hidden instead of closed with these buttons (Form1 is then "visible=true" when re-accessing this form.

The problem is...when closing Form1, the app doesn't shut down.  I have to manually stop it.  Driving me crazy!

(VB 5 & 6 were sooooo much easier!) - VB (all versions) novice here.

I'm guessing it has to do with different instances of Form1?  Assuming that when I hit the button on Form2 to show Form1 and close Form2, it's actually creating/showing a new instance of Form1 (???), and the original Form1 is still running hidden?

How can I reference instances of forms already running - hidden or not - without creating new instances?

Need some pretty low-brow explanations here...

Thanks much for any help.
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CThomp2005
CThomp2005

ASKER

Thanks for all the great input.  As this is my first endeavor using .NET, I find it a but "over my head" (and will eventually revert back to my good old VB5).  I haven't quite "translated" all the code provided into something I understand.  In the end, I've managed to pull off what I'm trying to do in this way.

Form1 - loads at app startup - I keep this on-screen at all times, maximized.  The "page" buttons on each page invoke the following:
  Dim Form2 as frmPage2  (<- inserting the appropriate page/form# for the form to go to).
  Form2.Show()
  Me.Close()

Each the button on each form invokes the next desired page maximized - to "cover up" the main screen (Form1).  Navigating back to the "main" form (Form1) simply invokes Me.Close(), as Form1 always stays put.

I have then removed the Min/Max buttons and Control Box on all forms aside from Form1 to ensure the program isn't closed/exited from anywhere but Form1.  Since Form1 never closes, when it IS closed, the app shuts down.

No doubt, an inefficient way to go, and will probably be a nightmare to upkeep, but is the only way I actually understand how it all works.

As mentioned above, I'll probably run back to VB5 and recreate the app there <sigh>.

Thanks for all your input and help.