WWW Yariv Hammer's Code Site

Wednesday, October 19, 2005

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:

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:

Public Shared Sub Main()
   Application.Run(New Form1())



Post a Comment

<< Home

Feel free to use everything here. Add links to my site if you wish.

Do not copy anything to other sites without adding link to here.

All the contents of the site belong to Yariv Hammer.