'Only Form1 in Startup Form in VS2022
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
Solution 1:[1]
I have the same issue. Both "Startup form" and "Enable application framework" are broken in Visual Studio 2022 when using VB.NET, WinForms, and .NET Framework. These both work if you target .NET 6.
My workaround is to close VS 2022, open the solution in VS 2019, set the Startup form, save, close VS 2019, and then re-open the solution in VS 2022.
Solution 2:[2]
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.
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BillB4 |
| Solution 2 | Marco Santoni |
| Solution 3 | Marco Santoni |


