Startup Event


Startup Event

Location

My.Application.Startup

Syntax

     Public Sub Me_Startup(ByVal sender As Object, _        ByVal e As StartupEventArgs) Handles Me.Startup     End Sub 


sender (required; Object)

The object that raised the event


e (required; StartupEventArgs)

An event parameter that contains information about the command-line arguments, using the Microsoft.VisualBasic.ApplicationServices.StartupEventArgs class

Description

The Startup event occurs when the application first starts. For single-instance applications, this event only occurs for the initial application startup.

Public Members

The e argument to this event, as an instance of the StartupEventArgs class, includes the following notable public members.

Member

Description

Cancel

Property. Setting this Boolean value to true causes the application to exit without displaying its main form.

CommandLine

Property. A collection of the command-line arguments. The application path itself is not one of the collection members; the first member is the first true argument.


Usage at a Glance

  • This event is only available in Windows Forms applications.

  • This event handler can be found in the ApplicationEvents.vb source code file for your project. This file is normally hidden, but it can be viewed by toggling the Show All Files button in the Solution Explorer window in Visual Studio.

Example

The Startup event's code appears in the ApplicationEvents.vb file in a Windows Forms application.

     Namespace My        Class MyApplication           Private Sub MyApplication_Startup(ByVal sender As Object, _                 ByVal e As Microsoft.VisualBasic.ApplicationServices. _                 StartupEventArgs) Handles Me.Startup              Console.WriteLine("Welcome.")           End Sub        End Class     End Namespace 

Related Framework Entries

  • Microsoft.VisualBasic.ApplicationServices.StartupEventArgs Class

  • Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Startup Event

See Also

Application Object, CommandLineArgs Property, Shutdown Event, StartupNextInstance Event, UnhandledException Event




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net