A normal (non-single-instance) application raises the Startup event every time it starts. A single-instance application raises the Startup event when it starts only if the application is not already active; otherwise, it raises the StartupNextInstance event. For more information, see My.Application.StartupNextInstance Event and How to: Specify Instancing Behavior for an Application (Visual Basic).
This event is part of the Visual Basic Application model. For more information, see Overview of the Visual Basic Application Model.
You can use the Cancel property of the e parameter to control the loading of an application's startup form. When the Cancel property is set to True, the startup form does not start. In that case, your code should call an alternate startup code path. For example, see How to: Enable a Batch Mode for Window Forms Applications.
You can use the CommandLine property of the e parameter or the My.Application.CommandLineArgs Property to access the application's command-line arguments.
The code for the Startup event handler is stored in the ApplicationEvents.vb file, which is hidden by default.
To access the Code Editor window for application events
With a project selected in Solution Explorer, click Properties on the Project menu.
Click the Application tab.
Click the View Application Events button to open the Code Editor.
For more information, see How to: Handle Application Events (Visual Basic).