Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.net Sub Main problem

Status
Not open for further replies.

drkarr

IS-IT--Management
Aug 10, 2005
24
US
I have programmed an application program (not web based) with several forms. Several versions worked fine by clicking the Solution Explorer Properties and selecting the name of the first form to be processed. Now the only thing that appears in the dropdown list, where all forms usually appear, is "Sub Main". I have tried the programming "fixes" in the module and class domains with no effect. How can I get my list of forms to reappear in place of "Sub Main"?
 
Project -> <Proj.name> Properties -> Common Properties @ General.
Startup object has the forms and the sub main.

If your app consists of many projects then right click on the project that contains the startup form you want -> Set as startup project, and then clarify (shown above) the startup object.

Hope this helps
 
Thanks for the response. We are on the same page, however my problem is that the forms do not appear in the Startup Object dropdown list--only Sub Main is there.
 
Is the application type set to windows application??
If there is only the sub main it must be "Class Library
 
Yes, the application type is set to Windows Application. When I type the name of the desired form in the window and click Apply, it changes back to Sub Main. When I try to build the application, I get the error message "Sub Main not foung in Form1". What a nightmare! I appreciate your help with this...
 
Is Sub Main declared as public?

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I have not previously dealt with "Sub Main" explicity so have never had occasion to declare it. I have always just checked the appropriate startup form in the "Startup Object" pulldown list in the project properties screen. The problem is that my forms no longer appear in that list; the only thing that now appears is "Sub Main" and it can't be changed by me.

Thanks for your interest Chip.
 
I just started a new Winforms Application and there is no "Sub Main" in my form at all. I think it's something that VB.net hides because it's there in c# and you're getting burned by VB.

Try Adding this to the form and then changing the start up object

<STAThread()> _
Public Shared Sub Main()
Application.Run(New Form1)


End Sub
 
One more thing...

<STAThread()> _
Public Shared Sub Main()
'CHange "form1" to the form you want to start up
Application.Run(New Form1)
End Sub
 
stsuing,

I suspect you are right, but I have no idea about how to overcome it. I tried your suggestion, which I appreciated, to no avail. I guess I'll start over and see if, when, and where (if at all) the problem recurs.

Many thanks to all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top