Learn about the differences in the Visual Basic 6 Project Explorer and the Visual Basic .NET Solution Explorer and about the differences of how VB6 and VB .NET manage project files and projects.
In Comparison between VB6 and .NET Objects Part 1 and Part 2, I covered the differences in the Properties Windows and in the Toolboxes respectively. With this article, I will concentrate on the differences in the Visual Basic 6 Project Explorer and the Visual Basic.NET Solution Explorer as well as explain the differences on how VB6 and VB.NET manages project files, and projects.
Let me start with explaining what a Project is in Visual Basic 6.
What Is a Project?
In Visual Basic 6, a project is the group of all the files that make up your program. These might include forms, modules (not attached to a form), graphics, and ActiveX controls.
Common File Extensions in a Visual Basic 6 Project
||Automatically generated file for every graphic in the project|
||Visual Basic Project|
||Control Binary File|
||Active Designer Cache|
||Package and Deployment Wizard CAB Information File|
||Package and Deployment Wizard Dependency File|
||ActiveX Document Form File|
||ActiveX Document Binary Form File|
||Active Designer File|
||Active Designer Binary File|
||Deployment Wizard Script File|
||Log file for Load Errors|
||Control TypeLib Cache File|
||Property Page File|
||Binary Property Page File|
||Remote Automation TypeLib File|
||Visual Basic Group Project File|
||Control Licensing File|
||Remote Automation Registration File|
||Visual Basic Project Workspace File|
||Wizard Launch File|
||WebClass HTML Template|
Creating a New Project
When Visual Basic 6 starts, you may be prompted with the following screen:
Otherwise, if the VB6 IDE is already opened, you can select
- New Project, and you will get the following screen:
Types of Projects
You can create the following types of projects with Visual Basic 6:
||Creates a standalone application.|
||Creates an out-of-process ActiveX component.|
||Creates an in-process ActiveX component.|
||Creates an ActiveX control, such as those that are shown in the Toolbox.|
|VB Application Wizard
||Choose whether you want to use the Application Wizard to provide the framework for your standalone application. Although the Application Wizard can save you time once you understand the fundamentals of building applications with Visual Basic, building your first few projects from scratch will make it simpler to enhance the wizard-generated code.|
|VB Wizard Manager
||Creates the framework for a wizard.|
|ActiveX Document DLL
||Creates an in-process ActiveX Document. An ActiveX Document is an application that can be run inside a special container, such as Office Binder or Internet Explorer.|
|ActiveX Document EXE
||Creates an out-of-process ActiveX Document.|
||Creates a special type of ActiveX server that can be used to enhance your Visual Basic Integrated Development Environment.|
||Creates a Standard EXE project that includes both a Data Environment Designer and a Data Report Designer.|
||Creates a Dynamic HTML project, which can be used to build DHTML Web pages.|
||Creates a project that can be used to build Active Server Pages.|
|VB Enterprise Edition Controls/VB Pro Edition Controls
||Creates a standalone application project, but automatically includes Enterprise/Professional controls, such as the Remote Data control in the Toolbox.|
When Visual Basic 6 starts, you may be prompted with the following screen. Notice the Existing and Recent tabs of the New Project Dialog box.
- The Existing tab allows you to browse for a particular project (or project group).
- The Recent tab allows you to select a project from a list of most recently opened projects.
You also can choose File, Open Project from the Visual Basic 6 main menu to open a project.
You will encounter the following dialog box:
Saving and Naming Projects
By default, Visual Basic 6 creates a project, named Project1, for you once you create a new project. There are two ways of changing its name, however:
- Click on Project in the Project Explorer Window
- Type in a new project name in the Properties Window
Examine Figure 5.
- Select Project from the Visual Basic 6 main menu.
- Select Project1 properties...
- On the General Tab, type in the new Project name in the Project Name field.
Examine Figure 6.
Changing a Project's Properties
Following Method 2 in the previous section will also allow you to access the Project's properties dialog. The Project Properties dialog contains the following tabs:
Adding Files to a Project
You can add additional existing Forms or Modules to your current project through the use of the Project Explorer. To add something to your project, follow these steps:
- Right-click anywhere in the Project Explorer
- Point to Add
- Select the item you want to add to your project
Examine Figure 7.
Removing Files from a Project
To remove an item from the current project, follow these steps:
- Right-click on the particular item to remove (in the Project Explorer).
- Select Remove ItemName from the displayed menu. Examine Figure 8.
Note: In Figure 8, the name of the item to be removed is Form1.
A project group contains more than one project simultaneously. Project groups are denoted with a .vbg extension. Examine Figure 9.
You create a project group by selecting by following these steps:
- Select File from the main Visual Basic 6 menu.
- Click Add Project. Your Project Explorer should now resemble Figure 9.
You remove a project from the project group by following these steps:
- Select the project to remove in the Project Explorer.
- Select File from the main Visual Basic 6 menu.
- Click Remove Project. The chosen project will be removed from the project group.
Using the Project Explorer
You keep track of all files in your project with the Project Explorer. The Project Explorer provides a method to organize your project's files and allows you to access them individually in Form or Code View. The files that are included in the project are listed in the Project Explorer window.
There are three toolbar buttons at the top of the Project Explorer Window; examine Figure 10.
- View Code: You can select any project module and click on the View Code button. This will open the Code window for that particular module. This allows you to view any program code contained in the module.
- View Object: The View Object button lets you open the designer for a module. To view the designer for a particular form, select the module from the project list and click on View Object.
- Toggle Folders: The Toggle Folders button allows you to view all modules organised within folders for the specific type of module or view all modules without the organising folder.
Most of your interaction with the Project Explorer will be with its context menu. When you right-click on one of your project's files, you'll see a menu similar to Figure 11.
The context menu allows you to:
- View the file in a form window or code window
- View the properties of the file
- Add a form or module to the project
- Print the file
- Make the project explorer float or docked to the IDE
- Hide the project explorer
Managing Resource Files
Resource files store data, such as strings or icons that would normally be hard coded into your program or stored in a database. Although this may seem an unnecessary step, it does make a lot of sense for certain applications. Resource files are typically used in applications that are to be distributed in foreign countries. The resource file can contain strings and other data that are designed specifically for the country in which the application is used.
For example, you could use a resource file to contain all of the strings that are displayed by a program. String resources are given a numeric identifier, and each identifier can have one or more language-specific strings associated with it: one for Afrikaans, one for German, one for French, and so on. This is referred to as Localization because the computer's locale ID (LCID) is used to determine which string to use. That way, you can have a single program that will automatically utilise the languages of different countries and you don't have to create separate versions for Afrikaans, German, French, and so on.
Using the Resource Editor
Now, look at how Visual Basic .NET differs from Visual Basic 6.
What Is a Project in Visual Basic .NET?
Projects in Visual Basic .NET are similar to projects in Visual Basic 6.0; however, there are some differences that you should be aware of.
In Visual Basic 6.0, projects used a reference-based model—the project file contained references to project items specifying their path. For example, when you added a text file to a project, the project file pointed to the location of the file; when the project was built, the text file would be loaded from that location.
Visual Basic .NET uses a folder-based model—all project items are placed in the project folder hierarchy. When you add a text file, a copy of the file is placed in the project folder; when the project is built, the text file is loaded from that copy of the file.
Common File Extensions in a Visual Basic.NET Solution
|Data Form Wizard
||.vb (.aspx for Web projects)|
|Web Custom Control
|Inherited User Control
|Assembly Resource File
|Assembly Information File
|Application Configuration File
|Windows Script Host
Creating a New Project in Visual Basic .NET
- On the File menu, select New Project.
- In the New Project dialog box, select a Project Type from the left pane.
- Select a project Template from the right pane.
- Enter a Name for the new project.
Note: For some project types, the Name textbox is unavailable because specifying the location sets the project name. For example, Web applications and XML Web services are located on a Web server and derive their name from the virtual directory specified on that server.
- Select a save Location.
- Select More.
- Select Create directory for Solution.
Note: This option is not available for Visual Basic Web or C# Web projects and other directory-based projects. For more information, see Item Management in Projects.
- Type a New Solution Name that differs from the project name.
- Select Open.
Note: You also can use this dialog box to add a new project to an open solution by selecting the Add to Solution radio button option. This option appears only when a solution is open in Solution Explorer.
Examine Figure 12.
|Visual Basic 6.0
||Visual Basic .NET|
||Windows Control Library|
||No equivalent. Visual Basic .NET can interoperate with ActiveX Documents.|
||No equivalent. Use ASP.NET Web Application.|
|IIS Application (Web Class)
||No equivalent. Use ASP.NET Web Application.|
Types of Projects that Can be Created Using Visual Basic .NET
||Used To Create|
|Windows Application Template
Traditional standalone Windows application or a rich front-end to a distributed Web application.
Note: This replaces the Standard EXE project template in Visual Basic 6.0.
|Class Library Template
||Reusable class or component that can be shared with other projects. This project type is considered windowless and will not contain a Windows Form class.|
|Windows Control Library Template
||Custom control to use on Windows Forms.|
|ASP.NET Web Application Template
||Programmable ASP.NET Web application.|
|ASP.NET Mobile Web Application Template
||ASP.NET Web Application viewable on PDAs (personal digital assistants), mobile phones, and other mobile devices.|
|ASP.NET Web Service Template
||XML Web services authored with ASP.NET, functionality that can be published and called by external applications.|
|Web Control Library Template
Custom control that can be used on Web Forms pages.
Note: This project type is analogous to the ActiveX Control project in Visual Basic 6.0.
|Console Application Template
|Windows Service Template
||Long running applications that do not have a user interface. Windows Service Applications (formerly called "NT services") can monitor items such as system performance.|
|New Project in Existing Folder Template
||Blank project within an existing application folder for using files from a pre-existing project. This template can be used with both local and Web projects.|
|Empty Project Template
||An empty project. The template creates the necessary file structure needed to store application information; any references, files, or components must be added manually.|
|Empty Web Project Template
||For advanced users who want to start programming in an empty environment and add their own server-based functionality.|
To open a Solution, follow these easy steps:
- Click File (on the main menu).
- Click Open Solution... You will be prompted with the following screen:
Below is a more detailed description of some of the options in the Open Solution dialog box.
||Locate the existing project folder from this list. Selecting a folder from this list displays the contents of the folder below.|
||Displays the files most recently opened solutions.|
||Displays the files and folders at the location specified in the Projects and Solutions, Environment, Options Dialog Box.|
||Displays the files and folders located on the desktop.|
||Displays the contents of your Internet Explorer Favorites folder.|
|My Network Places
||Displays the contents of your My Network Places folder. Use Add Network Place to add another network resource to this folder for easy retrieval.|
|Add to Solution
Select this radio button to add the project to the current solution. The solution will remain open in the integrated development environment (IDE). This option appears only when a solution is already open.
Note: Choosing to open the project in the current solution adds the project to the solution just as you can in the Add Existing Project dialog box.
||Select this radio button to close the current solution before you open the selected project. Visual Studio will prompt you to save changes to any project items before closing the solution. If Visual Studio is unable to find the project's parent solution, a new solution is created in an unsaved state. This option appears only when a solution is already open.|
||Use this option to filter the files and folders that are displayed. Enter a full or partial file name on which to filter. You can use the asterisk (*) as a wildcard.|
|Files of type
||Use this option to filter the files displayed based on file extension. Each product lists default filters of the most common file types.|
Saving and Naming Projects
Visual Basic .NET does not create a project with a default name, like in Visual Basic 6. When you create a new Solution, you specify the name in the New Solution dialog box. However, you can do the following:
- Change the Assembly name, in the Project property pages, by selecting Project, ProjectName Properties from the main menu. Examine Figure 14.
Description of Figure 14:
||Shows the name of the output file that will hold the assembly manifest. Changing this property also will change the Output Name property.|
||Indicates the type of application to build. In a Web Application project, this property can only be set to Class Library.|
||Defines the entry point to be called when the application loads; generally, this is set to either the main form in your application or to the Sub Main procedure that should run when the application starts. Because Class Libraries do not have an entry point, their only option for this property is (None).|
||Sets the base namespace for all files in the project. For example, if you set the root namespace to Project1 and you have a Class1 outside of any namespace in your code, its namespace would be Project1.Class1. If you have a Class2 within a namespace Order in code, its namespace would be Project1.Order.Class2.|
||Identifies the full path to the folder in which the .vbproj file is located for the application, or the URL path for Web-based projects.|
||Sets the name of the .vbproj file that represents the project on disk or on a Web server.|
||Sets the name of the compiled output of the application; for example, myproject.exe. The Assembly Name is combined with the default extension for the Output Type to form this filename.|
- Save Solution items individually, under a different name: By selecting the item in the Solution Explorer and selecting Save FileName.FileExtension As... from the File menu
Apply a new language encoding scheme to the saved file: To achieve this, open a code file for editing in Visual Studio and choose Advanced Save Options on the File menu.
You will be prompted with the following screen:
||Use this list box to apply a new language encoding scheme to the target file.|
||To ensure that the target file will run on a specific operating system, select whether a carriage return (for Macintosh systems), a line feed (for Unix systems), or both characters (for Windows systems) will mark the end of each line.|
Adding Files to a Solution
To add Items to your solution, right-clickon the Solution name in the Solution Explorer, point to Add, and select the desired item from the displayed list. Examine Figure 16.
Removing Files from a Solution
For projects that manage items as links, you can remove an item from your project. The link is removed from Solution Explorer; the item's file is disassociated from the project, but not permanently removed from storage. Projects that manage the items as files instead of links do not support the Remove command.
To remove an item or project
- In Solution Explorer, select the item you want to remove.
- On the Edit menu, select Remove.
Deleting Files from a Solution
For projects that manage items as files or either files or links, you can delete an item from your project. The link is removed from Solution Explorer; the item's file is permanently removed from storage. Projects that manage the items as links do not support the Delete command.
To permanently delete an item
- In Solution Explorer, select the item you want to delete.
- On the Edit menu, select Delete.
Excluding Files from a Solution
By using the Exclude command, you can temporarily remove an item from the project build. After excluding the file, you can subsequently re-introduce it with Show All Files. For projects that manage items as file or either files or links, you can exclude an item from your project.
Including and excluding files is one way to customize the output of your applications for specific target audiences. For example, if you are developing both English and Chinese versions of an e-commerce application, you can exclude the English components of your user interface when building the Chinese version and vice versa.
To temporarily exclude an item that represents a file
- In Solution Explorer, select the item you want to exclude.
- On the Project menu, select Exclude From Project.
Unloading Files from a Solution
To temporarily unload a project from a solution
- In Solution Explorer, select the project you want to unload.
- On the Project menu, select Unload Project.
Managing Project Groups in Visual Basic .NET
In Visual Basic 6.0, multiple projects could be added in the Project Explorer; multiple projects were called Project Groups. In Visual Basic .NET, Solution Explorer replaces the Project Explorer; Project Groups are replaced by solutions. Where Project Groups could only contain Visual Basic projects, solutions can contain projects created in any combination of Visual Studio .NET languages.
In Visual Basic 6.0, project files (.vbp) and project group files (.vbg) were text files that could be edited directly in a text editor. In Visual Basic .NET, project and solution files are in an XML format; they should not be edited directly. Figure 17 shows an example of having more than one project open in a Solution.
To add more projects to your current solution, Select Add Project from the File menu.
Using the Solution Explorer
The Solution Explorer provides you with an organized view of your projects and their files as well as ready access to the commands that pertain to them. A toolbar associated with this window offers commonly used commands for the item you highlight in the list. To access Solution Explorer, select Solution Explorer on the View menu.
A project shown in bold font is selected as the Startup Project for running and debugging purposes. If there is more than one startup project, the solution node in the tree view is shown in bold font. Startup projects run automatically when you start the Visual Studio debugger. By default, the first project created in the solution is designated as the startup project, but you can easily change which projects run first when you Build or Run your solution.
You can open files, add and remove items, and perform other management tasks. Each project template provides its own folders and icons for indicating the nature of the items in the project. You can add folders and items to meet the needs of your individual development project. The icons can indicate a variety of information about an item. For example, depending on the project, you might see an icon indicating that an item is an HTML file or that a file is under source control. Each project template also determines which tools and designers are associated with a file type as well as the commands available for item management.
You can select multiple items in a single project or multiple items spanning several projects. Select multiple items when you want to perform batch operations (simultaneously opening multiple files for editing, for example) or when you want to determine or edit the intersecting properties of two or more solution items. When you select multiple items, the available commands represent the intersection of commands common to all selected items.
Solution Explorer Toolbar
Based on Figure 18, a description of the toolbar buttons follows:
||Opens the selected file for editing in the Code Editor|
||Opens the selected file for editing in the Form Designer|
Refreshes the state of the items in the selected project or solution
Note: If you are a member of a development team working with shared project files that are merged and kept under source control, select this button to display the current state of the files included in your active solution.
|Show All Files
||Shows all project items, including those that have been excluded and those that are normally hidden. The project initially determines which project items are hidden.|
||Displays the property user interface as appropriate for the selected item in the tree view|
Managing Resource Files
How to use Resource files in Visual Basic .NET
In the whole Comparison between Visual Basic 6 and Visual Basic .NET series, I have explained some of the major differences between VB6 and VB .NET. However, this is just the tip of the iceberg, but it is still more than enough to get you started on Visual Basic .NET, and to make your migration a bit easier.