Visual Basic Concepts
Working with files within a project is similar to working with the projects themselves.
To add a file to a project
The Add filetype dialog box (Figure 4.2) is displayed.
Figure 4.2 The Add Form dialog box
When you add a file to a project, you are simply including a reference to the existing file in the project; you are not adding a copy of the file. Therefore, if you make changes to a file and save it, your changes will affect any project that includes the file. To change a file without affecting other projects, select the file in the Project Explorer, choose Save filename As from the File menu, and then save the file under a new file name.
Note You can drag and drop files from the Windows Explorer, File Manager, or Network Neighborhood into the Project window to add them to a project. You can also drag and drop .ocx files onto the toolbox to add new controls.
To remove a file from a project
If you remove a file from a project, Visual Basic updates this information in the project file when you save it. If you delete a file outside of Visual Basic, however, Visual Basic cannot update the project file; therefore, when you open the project, Visual Basic displays an error message warning you that a file is missing.
To save an individual file without saving the project
You can also insert existing text from other files into one of your code modules. This is useful for adding a list of constants or for adding snippets of code that you might have saved in text files.
To insert a text file into your code
Note If you edit Visual Basic source files using a text or code editor other than Visual Basic, be careful not to change settings of the attribute VB_PredeclaredId. In particular, changing this attribute may cause serious problems with the GlobalMultiUse and GlobalSingleUse classes.
In general, you should not edit attributes manually, as doing so may put the module into an internally inconsistent state.