How-to create a Main method in VB.NET
How-to create a Main method in VB.NET
In C# the designer automatically creates a Main method inside the first form. It looks like this:
--------------------------
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
--------------------------
In VB.NET however this is not the default behavior. If you need a Main method follow this steps:
1. In Solution Explorer right-click on the project name and select Properties.
2. In the General Tab (the one that is opened) you have Startup Object
3. Select either a form, or Sub Main option (in our case).
4. Add the following code somewhere in your code:
--------------------------------
<STAThread>_
Public Shared Sub Main()
{
Application.Run(New Form1())
}
-------------------------------
0 Comments:
Post a Comment
<< Home