I'm coding a project in Visual Basic using Visual Studio 2022 and want to start the program with a particular form. I have currently 8 forms. When I go to Solution Explorer/Properties/Application and select Startup Form, only a form named Form1 is in the dropdown list. I have tried as much as I'm game as I'm afraid of messing it all up. I'm a new self taught programmer. Hope someone can help with not too much tech jargon.
Leif
CodePudding user response:
Look in the Main method, there should be an Application.Run(New Form1())
call or similar. You can change Form1
to the form you want to run.
Remember that in the project properties you must set Main as the start object.
CodePudding user response:
With .NET Framework you can create a class (eg. Program) with a static method (Shared in VB) called Main and set this method as startup object in the project properties and, as above mentioned, uncheck Enable application framework flag.
In the Main method you can start your preferred form using Application.Run
.
Public Class Program
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(True)
Application.Run(New Form2())
End Sub
End Class