Share via


How to: Change the Startup Object for an Application (Visual Basic)

The Startup object or Startup form property for a project defines the entry point to be called when the application loads. Generally you set this either to the main form in your application or to the Sub Main procedure that should run when the application starts.

You can set the Startup object or Startup form property in the Application page of the Project Designer. For more information, see Application Page, Project Designer (Visual Basic).

The Startup form/Startup object option in the Project Designer depends on the project type. For example, a Console Application has a Startup Object option, which can be Sub Main or Module1. A Windows Application has a Startup Form option, which can be Form1 or Sub Main (see following note). Because class libraries do not have an entry point, their only option for this property is (None).

The Enable application framework option specifies whether a project will use the application framework. This setting affects the options available in Startup form/Startup object:

  • If Enable application framework is selected (the default), the option is Startup form, and shows only forms because the application framework only supports startup forms, not objects.

  • If Enable application framework is cleared, this option becomes Startup object and shows forms and classes, or modules with a Sub Main. When you disable the application framework, your application uses a custom Sub Main procedure that you have created, and you must add code in the Sub Main procedure for the form.

    When using a custom Sub Main procedure as the Startup object, code in the application events (Startup, Shutdown, StartupNextInstance, and UnhandledException) is not executed.

To change the startup object or startup form

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Click the Application tab.

  3. Select a Startup object from the Startup object or Startup form drop-down list.

To set the startup object for a Windows Application to Sub Main

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.

  2. Click the Application tab.

  3. Clear the Enable application framework check box.

  4. Select Sub Main from the Startup object drop-down list.

See Also

Reference

Application Page, Project Designer (Visual Basic)

Other Resources

Managing Application Properties

Change History

Date

History

Reason

July 2009

Modified information about the Enable application framework option.

Customer feedback.