load form

I've looked everywhere in the Help file but such a simple question I can't find.

In VB6
Sub Main()
Form1.Show
End Sub

in VB7, I got this far
Imports System.Windows.Form

Sub Main()
Dim f as New Form1
f.Show
End Sub

and it does, but then the End Sub stops the app.
Why?
LVL 4
broadbentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Sub Main
    Application.Run(New Form1)
End Sub
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Also take a look at the techniques I present in this PAQ for switching between forms:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21274481.html

They make use of the ApplicationContext() class:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsapplicationcontextmemberstopic.asp

Also, if you don't need main, then change your Project properties to start with Form1 instead.

~IM
0
broadbentAuthor Commented:
Thanks, but Form1 is not defined. How do I do this?
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
>> Form1 is not defined.

Eh?!

>> Sub Main()
>> Dim f as New Form1
>> f.Show
>> End Sub

>> and it does, but then the End Sub stops the app.

You said in your original description that the code works...so you must have a Form1 defined or it wouldn't compile.

Go to Project --> Properties and change the "Output Type" from "Console Application" to "Windows Application".  If you need a form in your project then go to Project --> Add Windows Form.

~IM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
broadbentAuthor Commented:
I was looking for wrong name!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.