Click to See Complete Forum and Search --> : compile error from the start?


pgugel
December 11th, 2002, 08:24 AM
I have just started trying to learn VB .Net. I created a new windows application project that consists of nothing but an empty form. When I try to run the form I get the following compile error:

'Sub Main' not found in TestApp.Form1.

I looked in my book for any clues and noticed that a console application contains code in the Sub Main routine. Is the project I created somehow having an identity crisis? How can I fix this?

Please help...:confused:

TheCPUWizard
December 11th, 2002, 08:32 AM
Two Questions:

1) EXACTLY how did you create the app?

2) What is your startup set to in the project properties?

Jym
December 11th, 2002, 09:43 AM
sub main is the first form that is opened when you run an application, what you did was change that form name from form1 to something else and it's still looking for form1 as the first form to open. so you have to set your "new name" to be the sub main form. it's easier to always name your form before they are created that way you don't have to change things later, so when you are adding a form, and you get the dialog box to add the form, change formX.vb to what you want the form to be named then you won't have to worry about changing "stuff" when you rename it.

pgugel
December 11th, 2002, 12:15 PM
To answer CPUWizard's questions -

1. I opened Microsoft Visual Studio .Net. Then from the start page I chose new project and selected VB .net Windows App.

2. I deleted my first attempt. When I did it the second time WITHOUT renaming the Form, I noticed that under project properties, the startup object was configured as Form1 - not Sub Main.

I ran the empty windows app successfully this time.

Thanks for the quick response!