Sub Main Ends so does the application

R

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?
 
G

Guest

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
 
G

GhostInAK

Hello Jim,

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

or, optionally Application.Run(new Form1)


-Boo
 
C

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
 
Z

zacks

Cor said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top