469,904 Members | 2,446 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

Lauching a form from another form

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?

Jul 13 '06 #1
4 978
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
Jul 13 '06 #2
When you use Sub Main (you must have to uncheck) use application
framework. so you do not have shutdown mode optioins available.

Jul 13 '06 #3
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
Jul 13 '06 #4

c_shah wrote:
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.

Jul 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Thang Nguyen | last post: by
4 posts views Thread by William Wisnieski | last post: by
2 posts views Thread by ColinWard | last post: by
6 posts views Thread by MP | last post: by
18 posts views Thread by Colin McGuire | last post: by
5 posts views Thread by ortaias | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.