While it is possible to create a Visual Basic application working entirely outside of Visual Studio 2010, it is much easier to start from Visual Studio 2010. After you install Visual Studio you are presented with a screen similar to the one shown in Figure 1-1. Different versions of Visual Studio may have a different overall look, but typically the start page lists your most recent projects on the left, some tips for getting started, and a headline section for topics on MSDN that might be of interest. You may or may not immediately recognize that this content is HTML text; more important, the content is based on an RSS feed that retrieves and caches articles appropriate for your version of Visual Studio.
The start page looks similar regardless of which version of Visual Studio 2010 you are running. Conceptually, it provides a generic starting point either to select the application you intend to work on, to quickly receive vital news related to offers, as shown in the figure, or to connect with external resources via the community links.
Once here, the next step is to create your first project. Selecting File O New Project opens the New Project dialog, shown in Figure 1-2. This dialog provides a selection of templates customized by application type. One option is to create a Class Library project. Such a project doesn't include a user interface; and instead of creating an assembly with an .exe file, it creates an assembly with a .dll file. The difference, of course, is that an .exe file indicates an executable that can be started by the operating system, whereas a .dll file represents a library referenced by an application.
One of the ongoing challenges with describing the menu options for Visual Studio is that the various versions have slight differences in look and feel too numerous to mention. For example File C- New Project in Visual Basic Express becomes File C- New O Project in Visual Studio. Thus, your display may vary slightly from what is shown or described here, although we attempt to showcase significant differences.
Figure 1-2 includes the capability to target a specific .NET version in the drop-down box located above the list of project types. In Figure 1-2 this shows .NET 2.0, and with only six project types below the selection listed. With .NET 4 selected, as shown in Figure 1-3, the number of project types has increased.
Targeting keeps you from attempting to create a project for WPF without recognizing that you also need at least .NET 3.0 available on the client. Although you can change your target after you create your project, be very careful when trying to reduce the version number, as the controls to prevent you from selecting dependencies don't check your existing code base for violations. Changing your targeted framework version for an existing project is covered in more detail later in this chapter.
Not only can you choose to target a specific version of the framework when creating a new project, but this window has a new feature that you'll find all over the place in Visual Studio 2010. In the upper-right corner, there is a control that enables you to search for a specific template. As you work through more of the windows associated with Visual Studio, you'll find that a context-specific search capability has often been added to the new user interface.
Expanding the top level of the Visual Basic tree in Figure 1-3 shows that a project type can be further separated into a series of categories:
V Windows — These are projects used to create applications that run on the local computer within the CLR. Because such projects can run on any operating system (OS) hosting the framework, the category "Windows" is something of a misnomer when compared to, for example, "Desktop."
V Web — You can create these projects, including Web services, from this section of the New Project dialog.
V Office — Visual Studio Tools for Office (VSTO). These are .NET applications that are hosted under Office. Visual Studio 2010 includes a set of templates you can use to target Office 2010, as well as a separate section for templates that target Office 2007.
V Cloud Services: — These are projects that target the Azure online environment model. These projects are deployed to the cloud and as such have special implementation and deployment considerations.
V Reporting — This project type enables you to create a Reports application.
V SharePoint — This category provides a selection of SharePoint projects, including Web Part projects, SharePoint Workflow projects, Business Data Catalog projects, as well as things like site definitions and content type projects. Visual Studio 2010 includes significant new support for SharePoint.
V Silverlight — With Visual Studio 2010, Microsoft has finally provided full support for working with Silverlight projects. Whereas in the past you've had to add the Silverlight SDK and tools to your existing development environment, with Visual Studio 2010 you get support for both Silverlight projects and user interface design within Visual Studio.
V Test — This section is available only to those using Visual Studio Team Suite. It contains the template for a Visual Basic Unit Test project.
V WCF — This is the section where you can create Windows Communication Foundation projects.
V Workflow — This is the section where you can create Windows Workflow Foundation (WF) projects. The templates in this section also include templates for connecting with the SharePoint workflow engine.
Visual Studio has other categories for projects, and you have access to other development languages and far more project types than this chapter has room for. When looking to create an application you will choose from one or more of the available project templates. To use more than a single project to create an application you'll leverage what is known as a solution. A solution is created by default whenever you create a new project and contains one or more projects.
When you save your project you will typically create a folder for the solution, then later if you add another project to the same solution, it will be contained in the solution folder. A project is always part of a solution, and a solution can contain multiple projects, each of which creates a different assembly. Typically for example you will have one or more Class Libraries that are part of the same solution as your Windows Form or ASP.NET project. For now, you can select a Windows Application project template to use as an example project for this chapter.
For this example, use ProVB_VS2010 as the project name to match the name of the project in the sample code download and then click OK. Visual Studio takes over and uses the Windows Application template to create a new Windows Forms project. The project contains a blank form that can be customized, and a variety of other elements that you can explore. Before customizing any code, let's first look at the elements of this new project.
Was this article helpful?