Visual Basic 2005 for Programmers (2nd Edition)

2.2. Overview of the Visual Studio 2005 IDE

There are many versions of Visual Studio available. The book's examples are based on the Microsoft Visual Basic 2005 Express Edition, which supports only the Visual Basic programming language. Microsoft also offers a full version of Visual Studio 2005, which includes support for other languages in addition to Visual Basic, such as Visual C# and Visual C++. Our screen captures and discussions focus on the IDE of the Visual Basic 2005 Express Edition. We assume that you have some familiarity with Windows.

Again, we use fonts to distinguish between IDE features (such as menu names and menu items) and other elements that appear in the IDE. We emphasize IDE features in a sans-serif bold Helvetica font (e.g., File menu) and emphasize other elements, such as file names (e.g., Form1.vb) and property names (discussed in Section 2.4.3), in a sans-serif Lucida font.

Introduction to Microsoft Visual Basic 2005 Express Edition

To start Microsoft Visual Basic 2005 Express Edition in Windows XP, select Start > All Programs > Microsoft Visual Basic 2005 Express Edition. For Windows 2000 users, select Start > Programs > Microsoft Visual Basic 2005 Express Edition. Once the Express Edition begins execution, the Start Page displays (Fig. 2.1) Depending on your version of Visual Studio, your Start Page may look different. For new programmers unfamiliar with Visual Basic, the Start Page contains a list of links to resources in the Visual Studio 2005 IDE and on the Internet. From this point forward, we will refer to the Visual Studio 2005 IDE simply as "Visual Studio" or "the IDE." For experienced developers, this page provides links to the latest developments in Visual Basic (such as updates and bug fixes) and to information on advanced programming topics. Once you start exploring the IDE, you can return to the Start Page by selecting View > Other Windows > Start Page. We use the > character to indicate the selection of a menu command from a menu. For example, we use the notation File > Open File to indicate that you should select the Open File command from the File menu.

Figure 2.1. Start Page in Visual Basic 2005 Express Edition.

Links on the Start Page

The Start Page links are organized into sectionsRecent Projects, Getting Started, Visual Basic Express Headlines and MSDN: Visual Basic 2005 Express Editionthat contain links to helpful programming resources. Clicking any link on the Start Page displays relevant information associated with the specific link. We refer to single clicking with the left mouse button as selecting, or clicking; we refer to double clicking with the left mouse button simply as double clicking.

The Recent Projects section contains information on projects you have recently created or modified. You can also open existing projects or create new ones by clicking the links in the section. The Getting Started section focuses on using the IDE for creating programs, learning Visual Basic, connecting to the Visual Basic developer community (i.e., other software developers with whom you can communicate through newsgroups and Web sites) and providing various development tools such as starter kits. For example, clicking the link Use a Starter Kit provides you with resources and links for building a simple screen saver application or a movie collection application. The screen saver application builds a screen saver that displays current news articles. The movie collection starter kit builds an application that lets you maintain a catalog of your DVDs and VHS movies, or the application can be changed to track anything else you might collect (e.g., CDs, video games).

The Getting Started, Visual Basic Express Headlines and MSDN: Visual Basic 2005 Express Edition sections provide links to information about programming in Visual Basic, including a tour of the language, new Visual Basic 2005 features and online courses. To access more extensive information on Visual Studio, you can browse the MSDN (Microsoft Developer Network) online library at msdn2.microsoft.com. The MSDN site contains articles, downloads and tutorials on technologies of interest to Visual Studio developers. You can also browse the Web from the IDE using Internet Explorer. To request a Web page, type its URL into the location bar (Fig. 2.2) and press the Enter keyyour computer, of course, must be connected to the Internet. (If the location bar is not already displayed, select View > Other Windows > Web Browser or type <Ctrl><Alt>R.) The Web page that you wish to view will appear as another tab, which you can select, inside the Visual Studio IDE (Fig. 2.2).

Figure 2.2. Displaying a Web page in Visual Studio.

Customizing the IDE and Creating a New Project

To begin programming in Visual Basic, you must create a new project or open an existing one. There are two ways to create a new project or open an existing project. You can select either File > New Project... or File > Open Project..., which creates a new project or opens an existing project, respectively. From the Start Page, under the Recent Projects section, you can also click the links Create: Project... or Open: Project.... A project is a group of related files, such as the Visual Basic code and any images that might make up a program. Visual Studio 2005 organizes programs into projects and solutions, which contain one or more projects. Multiple-project solutions are used to create large-scale programs. Each of the programs we create in this book consists of a single project.

Select File > New Project... or the Create: Project... link on the Start Page to display the New Project dialog (Fig. 2.3). Dialogs are windows that facilitate user-computer communication. We will discuss the detailed process of creating new projects momentarily.

Figure 2.3. New Project dialog.

Visual Studio provides templates for a variety of projects (Fig. 2.3). Templates are the project types users can create in Visual BasicWindows applications, console applications and others (you will primarily use Windows applications and console applications in this textbook). Users can also create their own custom application templates. In this chapter, we build a Windows Application. We discuss the Console Application template in Chapter 3, Introduction to Visual Basic Programming. A Windows application is a program that executes within a Windows operating system (e.g., Windows 2000 or Windows XP) and typically has a graphical user interface (GUI)the visual part of the program with which the user interacts. Windows applications include Microsoft software products like Microsoft Word, Internet Explorer and Visual Studio; software products created by other vendors; and customized software that you and other programmers create. You will create many Windows applications in this text. [Note: Novell sponsors an open source project called Mono that enables developers to create .NET applications for Linux, Windows and Mac OS X. Mono is based on the Ecma standards for the Common Language Infrastructure (CLI). For more information on Mono, visit www.mono-project.com.]

By default, Visual Studio assigns the name WindowsApplication1 to the new project and solution (Fig. 2.3). Soon you will change the name of the project and the location where it is saved. Click OK to display the IDE in design view (Fig. 2.4), which contains all the features necessary for you to begin creating programs. The design view portion of the IDE is also known as the Windows Form Designer.

Figure 2.4. Design view of the IDE.

The gray rectangle titled Form1 (called a Form) represents the main window of the Windows application that you are creating. Visual Basic applications can have multiple Forms (windows); however, the applications you will create in this text use only one Form. Soon, you will learn how to customize the Form by adding controls (i.e., reusable components) to a programin this example, you'll add a Label and a PictureBox (Fig. 2.27). A Label typically contains descriptive text (e.g., "Welcome to Visual Basic!"), and a PictureBox displays an image, such as the Deitel bug mascot. Visual Basic Express has 66 pre-existing controls you can use to build and customize your programs. Many of these controls are discussed and used throughout the book. Other controls are available from third parties. You can download several third party controls from msdn.microsoft.com/vbasic/downloads/controls/default.aspx.

In this chapter, you will work with preexisting controls that are part of the FCL. As you place controls on the form, you'll be able to modify their properties (discussed in Section 2.4). For example, Fig. 2.5 shows where the Form's name can be modified in a text box and Fig. 2.6 shows a dialog in which a control's font properties can be modified.

Figure 2.5. Text box control for modifying a property in the Visual Studio IDE.

Figure 2.6. Dialog for modifying a control's font properties in the Visual Studio IDE.

Collectively, the Form and controls constitute the program's GUI. Users enter data (inputs) into the program by typing at the keyboard, by clicking the mouse buttons and in a variety of other ways. Programs use the GUI to display instructions and other information (outputs) for users to read. For example, the New Project dialog in Fig. 2.3 presents a GUI where the user clicks the mouse button to select a template type, then inputs a project name from the keyboard (note that the figure is still showing the default project name WindowsApplication1 supplied by Visual Studio).

The name of each open document is listed on a tabin Fig. 2.4, the open documents are Form1.vb [Design] and the Start Page. To view a document, click its tab. Tabs facilitate easy access to multiple open documents. The active tab (the tab of the document currently displayed in the IDE) is displayed in bold text (e.g., Form1.vb [Design] in Fig. 2.4) and is positioned in front of all the other tabs.

Категории