In Chapter 2 you learned that you can create your VB.NET applications using Notepad. In this chapter, you'll learn why you never will. Microsoft developed Visual Studio .NET (VS.NET) to facilitate the creation of Windows and web applications. You will find that this Integrated Development Environment (IDE) is a very powerful tool that will greatly simplify your work.
Visual Studio .NET offers many advantages to the .NET developer. The following features are discussed in this chapter:
A modern interface using a tabbed document metaphor for source code and layout screens, and toolbars and informational windows that dock where you want them.
Code completion, which enables you to enter code with fewer errors and much less typing.
IntelliSense, which pops up help on every method and function call as you type.
Dynamic, context-sensitive help, which allows you to view topics and samples relevant to the code you are writing at the moment.
Immediate flagging of syntax errors (e.g., missing characters, misplaced braces, etc.), which allows you to fix problems as they are entered.
The ability to compile and test programs right in the IDE.
A built-in task list to keep track of changes you need to make.
A Start Page that provides easy access to new and existing projects.
Customization capability, which allows you to set user preferences for IDE appearance and behavior.
One VS.NET feature will be so important to you, even as a VB.NET novice, that it actually merits its own chapter: An integrated debugger, which enables you to step through code, observe program runtime behavior, and set breakpoints, even across multiple languages. The debugger is considered in detail in Chapter 10.
In addition to these basic capabilities, VS.NET provides a number of advanced features that will simplify the development process. These features include:
Convenient access to multiple design and code windows.
WYSIWYG (What You See Is What You Get) visual design of Windows forms and web forms.
An HTML editor, which provides both Design and HTML views that update each other in real time.
A Solution Explorer, which displays all the files that make up your solution (a collection of projects) in a hierarchical format.
A Server Explorer, which allows you to log on to servers to which you have network access, access the data and services on those servers, and perform a variety of other chores.
Integrated support for source control software.
Many of these advanced features are covered in detail in Programming ASP.NET and Programming .NET Windows Applications (both books cowritten by Jesse Liberty and Dan Hurwitz, published by O'Reilly).
Robert Heinlein said "TANSTAAFL: There ain't no such thing as a free lunch." While Visual Studio .NET can save you a lot of grunt typing (and in general greatly facilitate and accelerate the development process), on the negative side the automatically generated code can obscure what is really necessary to create good working applications. It is sometimes difficult to know how Visual Studio .NET accomplishes its legerdemain. Similarly, the proliferation of mysteriously named files across your filesystem can be disconcerting when all you want to do is a simple housekeeping chore, like rename a minor part of the project.
Since most of the applications we'll build in this book are console applications designed to illustrate the basics of the language, very little obscuring code will be produced. When you go on to create Windows and web applications, however, you'll want to learn to sort through the code Visual Studio .NET generates in order to focus on the logic of your program.
The current chapter cannot possibly teach you everything about Visual Studio .NET; it is far too large and complex an application. What this chapter does is give you the basics for getting started and also point out some of the possible pitfalls.
Keep in mind that there's no way to familiarize you with some of these features without wading into some slightly deeper waters of VB.NET programming, which will likely be a bit cloudy to you at this stage. As you get deeper into the book and learn more about the language, your understanding of VB.NET will become clearer.
The Start Page is the first thing you see when you open Visual Studio .NET (unless you configure it otherwise). From here you can create new projects or open a project you worked on in a previous session. You can also find out what is new in .NET, access .NET newsgroups and web sites, search for help online, download useful code, or adjust Visual Studio .NET to your personal requirements. Figure 4-1 shows a typical Start Page.
Along the top of the application window is a set of menus and buttons. These menus and buttons are context-sensitive (i.e., they will change as the current window changes).
A VB.NET program is built from source files, text files containing the code you write. Source code files are named with the .vb extension. The helloworld.vb file you created in Chapter 2 is a typical example.
A typical Visual Studio .NET application can have a number of other files (e.g., assembly information files, references, icons, data connections, etc.). VS.NET organizes these files into a container called a project.
Visual Studio .NET provides two types of containers for your source code, folders, files, and related material: the project and the solution. A project is a set of files that work together to create an executable program (.exe) or a dynamic link library (.dll ). Large, complex projects may consist of multiple .dll files called modules.
A solution is a set of one or more related projects. Each time you create a new project, Visual Studio .NET will either add it to an existing solution or create a new solution.
The .sln file contains metadata, which is basically information about the data. The metadata describes the projects that compose the solution and information about building the solution. Visual Studio .NET also creates a file with the same base name as the .sln file, but with the filename extension .sou (e.g., mySolution.sln and mySolution.sou). The .sou file contains metadata used to customize the IDE.
There are a number of ways to open an existing solution. The simplest is to select Open Project from the Start menu (which will open a project and its enclosing solution). Alternatively, you can open a solution in Visual Studio .NET just by double-clicking the .sln file in Windows Explorer.
Typically, the build process results in the contents of a project being compiled into an executable (.exe) file or a dynamic link library (.dll) file. This book focuses on creating executable files.
When you create a new project, you get the New Project dialog box, shown in Figure 4-2.
In the New Project dialog, you select the project type (in the lefthand pane) and the template (in the right). There are a variety of templates for each project type. A template is a file that Visual Studio .NET uses to set up the initial state of your project.
For the examples in this book, you'll always choose Visual Basic Projects for the project type, and in most cases, you'll choose Console Application as the template. Specify the name of the directory in which your project will be stored (any directory you like). At this point, you can also name your project. For the purposes of example, enter the name HelloWorld.
 Robert A. Heinlein, The Moon Is a Harsh Mistress (St. Martin's Press).