Home All Groups Group Topic Archive Search About

Lauching a form from another form

Author
13 Jul 2006 7:33 PM
c_shah
Windows form application

I have an accounting application, the main form of that application can
be launched  from other application passing the account number or it
can be started
as a standalone application. If it is started as a standalone
application It shoud prompt a dialog box asking for account number.
if the account number is valid it will launch a main form passing the
account number

I currently have a Sub Main(ByVal Args() As String) and I am passing
command line arguments it it is open from the other application

And no argument is passed I open up account number form but the thing
is as soon as I close the account number form it closes my entire
application.

any solution?

Author
13 Jul 2006 7:53 PM
iwdu15
fortunatly if your using 2005, theres a simple solution, in your project
properties theres an option of Exit Application When...and you can select
When First Form Closes or When last Form Closes....so pick when last form
closes.

if your using 2003....well i never quite took the time to figure out how to
stop that from happening....
--
-iwdu15
Author
13 Jul 2006 8:11 PM
c_shah
When you use Sub Main (you must have to uncheck) use application
framework. so you do not have shutdown mode optioins available.
Author
13 Jul 2006 8:32 PM
iwdu15
it may nto be the best method, but if your starting up from Sub main, make
your form variable a global variable, then in your form closing event, hide
your form. when you want to exit your app in other forms, say

Application.Exit()

and i know your not supposed to do this...but i forget the other way of
preventing this action
--
-iwdu15
Author
13 Jul 2006 8:46 PM
zacks
c_shah wrote:
Show quoteHide quote
> Windows form application
>
> I have an accounting application, the main form of that application can
> be launched  from other application passing the account number or it
> can be started
> as a standalone application. If it is started as a standalone
> application It shoud prompt a dialog box asking for account number.
> if the account number is valid it will launch a main form passing the
> account number
>
> I currently have a Sub Main(ByVal Args() As String) and I am passing
> command line arguments it it is open from the other application
>
> And no argument is passed I open up account number form but the thing
> is as soon as I close the account number form it closes my entire
> application.
>
> any solution?

I wrote a Sub Main based VB app (with VS2005) that opens a couple of
forms using the Form.Show method, and when those forms close, the app
doesn't end. And the code later opens the main form with an
Application.Run(mainform) command.

If the Sub Main code comes to the End Sub, the app will close. But the
Application.Run method keeps the app alive until the form referenced in
the .Run method is closed. At least that's how it works for me.