By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,045 Members | 2,120 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,045 IT Pros & Developers. It's quick & easy.

Keeping application alive starting from Sub Main()

P: n/a
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance
Nov 20 '05 #1
Share this Question
Share on Google+
22 Replies


P: n/a
Hi,
You could create a blank project and put a Sub Main() in it, this
would be the default startpoint. However, it is unlikely you would want to
do it this way really, you should try and think VB.NET rather than the old
way. For example, create a windows forms application in VB>NET and you will
find that your primary form ( Form1 ) is the startup class. when you run it
the form will appear.

regards - OHM

"Vell" <an*******@discussions.microsoft.com> wrote in message
news:17*****************************@phx.gbl...
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance

Nov 20 '05 #2

P: n/a
Hi,
You could create a blank project and put a Sub Main() in it, this
would be the default startpoint. However, it is unlikely you would want to
do it this way really, you should try and think VB.NET rather than the old
way. For example, create a windows forms application in VB>NET and you will
find that your primary form ( Form1 ) is the startup class. when you run it
the form will appear.

regards - OHM

"Vell" <an*******@discussions.microsoft.com> wrote in message
news:17*****************************@phx.gbl...
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance

Nov 20 '05 #3

P: n/a
Hi Vell,

If you are starting a form from Sub Main, you need to run it using
Application.Run so that a message loop is started and the application
doesn't terminate until the form is unloaded...

\\\
Public Sub Main()
Application.Run(New MyForm)
End Sub
///

Hope this helps,
Gary

"Vell" <an*******@discussions.microsoft.com> wrote in message
news:17*****************************@phx.gbl...
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance

Nov 20 '05 #4

P: n/a
Hi Vell,

If you are starting a form from Sub Main, you need to run it using
Application.Run so that a message loop is started and the application
doesn't terminate until the form is unloaded...

\\\
Public Sub Main()
Application.Run(New MyForm)
End Sub
///

Hope this helps,
Gary

"Vell" <an*******@discussions.microsoft.com> wrote in message
news:17*****************************@phx.gbl...
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance

Nov 20 '05 #5

P: n/a
Cor
Hi OHM,

My kind of style, I love you.
Nice to see those rows with people I did see so much last month

:-)

Cor
Nov 20 '05 #6

P: n/a
Cor
Hi OHM,

My kind of style, I love you.
Nice to see those rows with people I did see so much last month

:-)

Cor
Nov 20 '05 #7

P: n/a
Hi again,

thank you all...

Gary your tip works fine...

bye

-----Original Message-----
Hi Vell,

If you are starting a form from Sub Main, you need to run it usingApplication.Run so that a message loop is started and the applicationdoesn't terminate until the form is unloaded...

\\\
Public Sub Main()
Application.Run(New MyForm)
End Sub
///

Hope this helps,
Gary

"Vell" <an*******@discussions.microsoft.com> wrote in messagenews:17*****************************@phx.gbl...
Hi,
i'm moving my first steps in vb.NET world and i'm getting first troubles..

in vb6 i can start an application from Sub Main() and load for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance

.

Nov 20 '05 #8

P: n/a
Hi again,

thank you all...

Gary your tip works fine...

bye

-----Original Message-----
Hi Vell,

If you are starting a form from Sub Main, you need to run it usingApplication.Run so that a message loop is started and the applicationdoesn't terminate until the form is unloaded...

\\\
Public Sub Main()
Application.Run(New MyForm)
End Sub
///

Hope this helps,
Gary

"Vell" <an*******@discussions.microsoft.com> wrote in messagenews:17*****************************@phx.gbl...
Hi,
i'm moving my first steps in vb.NET world and i'm getting first troubles..

in vb6 i can start an application from Sub Main() and load for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?

Can anyone help me?
Thanks in advance

.

Nov 20 '05 #9

P: n/a
Well Cor, I really dont think saying "I Love you" was what you really meant,
at least I hope not. ! and that we are dealing with a language issue here !

I think what you meant to say was 'you like the way I answered the
question'.

Regards - OHM

"Cor" <no*@non.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi OHM,

My kind of style, I love you.
Nice to see those rows with people I did see so much last month

:-)

Cor

Nov 20 '05 #10

P: n/a
Well Cor, I really dont think saying "I Love you" was what you really meant,
at least I hope not. ! and that we are dealing with a language issue here !

I think what you meant to say was 'you like the way I answered the
question'.

Regards - OHM

"Cor" <no*@non.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi OHM,

My kind of style, I love you.
Nice to see those rows with people I did see so much last month

:-)

Cor

Nov 20 '05 #11

P: n/a
Cor
OHM,

No not real the language question, was just for fun to overdo it.

:-))

Cor
Nov 20 '05 #12

P: n/a
Cor
OHM,

No not real the language question, was just for fun to overdo it.

:-))

Cor
Nov 20 '05 #13

P: n/a
Thank God For That !

"Cor" <no*@non.com> wrote in message
news:ul*************@TK2MSFTNGP10.phx.gbl...
OHM,

No not real the language question, was just for fun to overdo it.

:-))

Cor

Nov 20 '05 #14

P: n/a
Thank God For That !

"Cor" <no*@non.com> wrote in message
news:ul*************@TK2MSFTNGP10.phx.gbl...
OHM,

No not real the language question, was just for fun to overdo it.

:-))

Cor

Nov 20 '05 #15

P: n/a
Cor,
Are you Male?
"Cor" <no*@non.com> wrote in message
news:ul*************@TK2MSFTNGP10.phx.gbl...
OHM,

No not real the language question, was just for fun to overdo it.

:-))

Cor

Nov 20 '05 #16

P: n/a
Cor,
Are you Male?
"Cor" <no*@non.com> wrote in message
news:ul*************@TK2MSFTNGP10.phx.gbl...
OHM,

No not real the language question, was just for fun to overdo it.

:-))

Cor

Nov 20 '05 #17

P: n/a
Cor
> Cor,
Are you Male?


LOL
Nov 20 '05 #18

P: n/a
Cor
> Cor,
Are you Male?


LOL
Nov 20 '05 #19

P: n/a
I'll take that as a yes then !
"Cor" <no*@non.com> wrote in message
news:ef**************@TK2MSFTNGP10.phx.gbl...
Cor,
Are you Male?


LOL

Nov 20 '05 #20

P: n/a
I'll take that as a yes then !
"Cor" <no*@non.com> wrote in message
news:ef**************@TK2MSFTNGP10.phx.gbl...
Cor,
Are you Male?


LOL

Nov 20 '05 #21

P: n/a
"Vell" <an*******@discussions.microsoft.com> schrieb
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?


Declaring it in a Module is no problem.
Shortest version:
sub main
application.run(new form1)
end sub

Or:
sub main
dim f as new form1
application.run(f)
end sub
Application.run starts the message loop that processes the windows messages
and keeps your application alive. It exits as soon as the passed form has
been closed. Application.run also shows the form first, so you don't have to
do it.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #22

P: n/a
"Vell" <an*******@discussions.microsoft.com> schrieb
Hi,
i'm moving my first steps in vb.NET world and i'm getting
first troubles..

in vb6 i can start an application from Sub Main() and load
for example a form using 'set' and 'show' command. The
output for the user will be the form and the program will
still run.

In vb .NET, if i made it in the same way, will be no
output for the user because the program terminate when the
execution reach the End Sub statement of the Sub Main().

I think this happens because the form is declared in
Module. There's a way to do so?


Declaring it in a Module is no problem.
Shortest version:
sub main
application.run(new form1)
end sub

Or:
sub main
dim f as new form1
application.run(f)
end sub
Application.run starts the message loop that processes the windows messages
and keeps your application alive. It exits as soon as the passed form has
been closed. Application.run also shows the form first, so you don't have to
do it.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.