Occurs when the application starts.
' Usage Public Sub Me_Startup( _ ByVal sender As Object, _ ByVal e As StartupEventArgs _ ) Handles Me.Startup End Sub ' Declaration Public Event Startup( _ ByVal sender As Object, _ ByVal e As StartupEventArgs _ )
The Object that raised the event.
Aobject that contains the application's command-line arguments.
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, seeand .
This event is part of the Visual Basic Application model. For more information, see.
You can use 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 .property of the
You can use the e parameter or the to access the application's command-line arguments.property of the
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.
This example uses the My.Application.SplashScreen property and the My.Application.Startup event to update the splash screen with status information as the application starts.
Private Sub MyApplication_Startup( _ ByVal sender As Object, _ ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs _ ) Handles Me.Startup ' Get the splash screen. Dim splash As SplashScreen1 = CType(My.Application.SplashScreen, SplashScreen1) ' Display current status information. splash.Status = "Current user: " & My.User.Name End Sub
This example requires that the project have a splash screen named SplashScreen1. The splash screen needs to have property named Status that updates its user interface.
You must enter the code in the Code Editor window for application events. To access this window, follow the instructions from this topic's Remarks section. For more information, see.