This documentation is archived and is not being maintained.

Visual Basic Concepts

Visual Studio 6.0

Working with Multiple Projects

You can create many applications by working with a single project. However, as your applications become more complex, you may want to work with multiple projects in the same session of the programming environment. For example, you may want to use one project to build an application's executable file, and a second project to serve as a "scratch pad" for testing code before you add it to the application.

You can add a new or existing project to your current editing session by adding it to a project group. You can then save the project group and work with it in subsequent editing sessions. You can open either the project group or an individual project in the project group, or add the project group or its individual projects to another project group.

In a project group, one executable project serves as a startup project. When a project group is open and you choose Start from the Run menu, click the Start button on the toolbar, or press F5, Visual Basic runs the startup project.

In the Professional or Enterprise edition, you can use project groups to create and debug multiple-component applications. For example, you can create and debug project groups containing standard executable projects, ActiveX executable projects, ActiveX dynamic-link library projects, or ActiveX control projects. For more information, see "Creating ActiveX Components" in the Component Tools Guide included with the Professional and Enterprise Editions of Visual Basic.

Adding or Removing a Project

When you create a new project either at startup or by selecting the New Project command on the File menu, Visual Basic automatically creates a project group for it. You can then add additional new or existing projects to the project group.

To add a new project to a project group

  • Click the Add Project button on the Toolbar or choose Add Project from the File menu.

    In Visual Basic, Learning edition, Visual Basic automatically adds a new executable project to the project group. In the Professional and Enterprise editions, you can select the type of project you want to add from the popup menu of the Add Project button, or the icons displayed in the New tab of the Add Project dialog box.

To add an existing project to a project group

  1. From the File menu, choose Add Project.

    Visual Basic displays the Add Project dialog box.

  2. Click the Existing tab.

  3. Select a project file, then choose Open.

    Visual Basic adds the selected project to the project group.

Visual Basic displays multiple projects in the Project window in a hierarchical view. Each project appears at the top level, with the project's forms, modules, controls, property pages, or document objects grouped under it in the hierarchical view.

Figure 8.1   The Project window with multiple projects

To remove a project from a project group

  1. Select the name of the project in the Project window.

  2. From the File menu, choose Remove Project.

    Visual Basic removes the selected project from the project group.

In the Professional and Enterprise editions of Visual Basic, you can change the type of a project by selecting the Project Properties command on the Project menu, then changing the Project Type option on the General tab in the Project Properties dialog box.

Figure 8.2   The General tab in the Project Properties dialog box

Specifying a Startup Project

Because a project group contains multiple projects, Visual Basic needs to know which project to run when you choose Start from the Run menu, click the Start button on the toolbar, or press F5. By default, Visual Basic runs the first executable (.exe) project that is added to a project group. However, you can specify a different startup component.

To specify a startup component

  1. In the Project window, select a project.

  2. Click the right mouse button and select Set as Start Up from the context menu.

Visual Basic displays the startup project's name in bold type in the Project window.

For More Information   Debugging multiple projects is discussed in "Debugging, Testing, and Deploying Components," in "Creating ActiveX Components" in the Component Tools Guide included with the Professional and Enterprise editions of Visual Basic.

Show: