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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start in Sub Main() 1

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,530
US
Venturing back to VB.NET (2022) world after many years in VB6
I would like to create a (Windows) Project, but start in [tt]Sub Main()[/tt] instead of Form1 since I do not need any forms/controls/etc. or any user input at all.

How do I do that in VB.NET 2022 [ponder]


---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Properties, Application, uncheck "Enable Application Framework", and Form start up will change to object startup.
 
Thank you SaltyTheFrog
Here is what I did in VB.NET 2022:

Create a new project
Windows Form App
-- type the name of your App --
Project - YourApp Properties
Application - General - Starup-object
(Starup-object already points to Sub Main, although App starts up with Form1)

Application Framework
un-check (Enable the Visual Basic Application Framework for this Projects...)
(Back to) Startp-object
Select: Sub Main

Project - Add Module...
(Name your Module if needed, Add)
Add code in Module:

[pre]
Sub Main()
MessageBox.Show("Hello World")
End Sub
[/pre]
In Solution Explorer, right-click Form1.vb - Delete - OK
Run your Project

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Hi Andy,
Is it some utility program that is run by Windows Scheduler, or manually?
Then you might want to consider making it a Console App.
Just a thought.
HTH.

Regards,

Ilya
 
Been away from vb.net for a while but I believe this is an easy fix.
(1) Open your project.
(2) Select the [Project } tab from top row
(3) Select [ Properties ] which should be at the bottom of the drop down list
(4) If the application form isn't showing select [ Application ] from the left column
(5) On the application form look for Startup Form, Select the form wanted from the drop down list
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top