In this section, you learn how to open and save a project, add and delete files from the Project window, give an object focus (further explained in later section “The Concept of Focus”), and use the other File commands provided with Visual Basic. You will also work through several exercises to rest your knowledge of the concepts presented.
Opening, Saving, Adding and Removing Projects
Whenever you open Visual Basic, you always start a new project. However, there are File commands that enable you to work with both old and new projects, and File and Project commands for working with old and new files. The File menu on the menu bar contains six commands designed for managing projects, as follows:
- New Projects – Choose File, New Project to start a new project. If you are working on a project, this command prompts you to save the current project. It then closes the current project to enable you to start a new one.
- Open Project - Choose File, Open Project to open a saved project. Before opening a project, this command asks if you want to save a current project if one exists.
- Add Project – Choose File, Add Project to open a saved project and add it to another, provided one exists. A Visual Basic application can contain any number of projects.
- Remove Project – Choose File, Remove Project to remove the selected project from a project group.
- Save Project As – Choose File, Save Project As to save the current project to a disk. This option always prompts you for a project name. Use this command to save a project for the first time or save a copy of an existing project. When first saving a project, you are asked whether or not you want to save each form and module associated with a project.
For each form or module, you can assign a name. You should name each form with a name other than the default name (such as form1.frm and form2.frm); otherwise, you will design over the form when you start a new project and find it impossible to retrieve the form you thought you had saved. You should also name each project with a unique name, or else Visual Basic will assign every project the same default name.
- Save Project – Choose File, Save Project to save the current project to a disk. this option saves all forms and modules as separate files. It creates a file with .VBP (Visual Basic Project) extension. If the project is being saved for the first time, this command prompts you for the project name. If saved earlier, it updates the .VBP file.
The .VBP file is saved as text or in ANSI (American National Standards Institute) format. This allows you to inspect its contents with any text editor. Each project contains one – and only one – .VBP file, which provides a description of the project, showing the names of the stored files and other descriptive information.
Secondary Storage Device