O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Start a Windows Application with a Main Subroutine

Problem

You want to start a Windows application without a startup form.

Solution

Create a module with a public Main method. Show all forms modally, or use the Application.Run method.

Discussion

There are several reasons that you might want to start a Windows application without using a startup form, including:

  • You want to show several forms at once.

  • You need to process command-line parameters (as described in recipe Retrieve Command-Line Parameters).

  • You need to programmatically decide which form to show initially.

  • You want to run your program in the background and provide a system tray icon that allows the user to access the full interface.

In these cases, you can start your application using a startup ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required