Home All Groups Group Topic Archive Search About

Sub Main Ends so does the application

Author
24 Jul 2006 6:45 PM
rrowe
Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------

Public Sub Main()

F1 = New Form1

Form1.Show()

End  Sub

All I am trying to do is show the form.   However, at the End Sub statement
the form closes..... I am confused.   Any ideas?

Author
24 Jul 2006 6:59 PM
iwdu15
if you want to use forms, create a Windows Application, at the end of the
sub, the program terminates, so if you want to use forms (usually) you want
to use a Windows Application
--
-iwdu15
Author
24 Jul 2006 7:03 PM
Jim Wooley
Use Application.Run(Form1) instead of Form1.Show()

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

Show quoteHide quote
> Admittedly, I am new to VB.NET
>
> I have some real simple code that I am trying to run in VB.NET
>
> Friend Module xxx
> Friend F1 As Form1
> -----------------
> Public Sub Main()
>
> F1 = New Form1
>
> Form1.Show()
>
> End  Sub
>
> All I am trying to do is show the form.   However, at the End Sub
> statement the form closes..... I am confused.   Any ideas?
>
Author
24 Jul 2006 8:37 PM
GhostInAK
Hello Jim,

Actually using the OP's original code fragment it would be Application.Run(F1)..

or, optionally Application.Run(new Form1)


-Boo

Show quoteHide quote
> Use Application.Run(Form1) instead of Form1.Show()
>
> Jim Wooley
> http://devauthority.com/blogs/jwooley/default.aspx
>> Admittedly, I am new to VB.NET
>>
>> I have some real simple code that I am trying to run in VB.NET
>>
>> Friend Module xxx
>> Friend F1 As Form1
>> -----------------
>> Public Sub Main()
>> F1 = New Form1
>>
>> Form1.Show()
>>
>> End  Sub
>>
>> All I am trying to do is show the form.   However, at the End Sub
>> statement the form closes..... I am confused.   Any ideas?
>>
Author
25 Jul 2006 5:52 AM
Cor Ligthert [MVP]
RRowe,

Just as addition,

Did you know that a VBNet mainform has an inbuild submain with an
application run as long as you have not done that yourself.

Cor

Show quoteHide quote
"rrowe" <rr***@hotmail.com> schreef in bericht
news:%23l3lWF1rGHA.3380@TK2MSFTNGP04.phx.gbl...
> Admittedly, I am new to VB.NET
>
> I have some real simple code that I am trying to run in VB.NET
>
> Friend Module xxx
> Friend F1 As Form1
> -----------------
>
> Public Sub Main()
>
> F1 = New Form1
>
> Form1.Show()
>
> End  Sub
>
> All I am trying to do is show the form.   However, at the End Sub
> statement
> the form closes..... I am confused.   Any ideas?
>
Author
25 Jul 2006 1:07 PM
zacks
Cor Ligthert [MVP] wrote:
> RRowe,
>
> Just as addition,
>
> Did you know that a VBNet mainform has an inbuild submain with an
> application run as long as you have not done that yourself.
>
> Cor

But if you want to do things like enable visual styles, read a config
file or manually display a splash screen, you will need to make it.

Show quoteHide quote
>
> "rrowe" <rr***@hotmail.com> schreef in bericht
> news:%23l3lWF1rGHA.3380@TK2MSFTNGP04.phx.gbl...
> > Admittedly, I am new to VB.NET
> >
> > I have some real simple code that I am trying to run in VB.NET
> >
> > Friend Module xxx
> > Friend F1 As Form1
> > -----------------
> >
> > Public Sub Main()
> >
> > F1 = New Form1
> >
> > Form1.Show()
> >
> > End  Sub
> >
> > All I am trying to do is show the form.   However, at the End Sub
> > statement
> > the form closes..... I am confused.   Any ideas?
> >
Author
25 Jul 2006 1:25 PM
Cor Ligthert [MVP]
> But if you want to do things like enable visual styles, read a config
> file or manually display a splash screen, you will need to make it.
>

Or maybe as showed on this page?

http://msdn2.microsoft.com/en-us/library/ms233841.aspx

Cor

<za***@construction-imaging.com> schreef in bericht
Show quoteHide quote
news:1153832848.890681.129930@m73g2000cwd.googlegroups.com...
>
> Cor Ligthert [MVP] wrote:
>> RRowe,
>>
>> Just as addition,
>>
>> Did you know that a VBNet mainform has an inbuild submain with an
>> application run as long as you have not done that yourself.
>>
>> Cor
>
> But if you want to do things like enable visual styles, read a config
> file or manually display a splash screen, you will need to make it.
>
>>
>> "rrowe" <rr***@hotmail.com> schreef in bericht
>> news:%23l3lWF1rGHA.3380@TK2MSFTNGP04.phx.gbl...
>> > Admittedly, I am new to VB.NET
>> >
>> > I have some real simple code that I am trying to run in VB.NET
>> >
>> > Friend Module xxx
>> > Friend F1 As Form1
>> > -----------------
>> >
>> > Public Sub Main()
>> >
>> > F1 = New Form1
>> >
>> > Form1.Show()
>> >
>> > End  Sub
>> >
>> > All I am trying to do is show the form.   However, at the End Sub
>> > statement
>> > the form closes..... I am confused.   Any ideas?
>> >
>