2.1 Introduction
2.2 Integrated Development Environment Overview
2.3 Project Window
2.4 Toolbox
2.5 Form Layout Window
2.6 Properties Window
2.7 Menu Bar and Tool Bar
2.8 A Simple Program: Displaying a Line of Text
Visual Basic’s Integrated Development Environment (IDE) allows the programmer to cre- ate, run and debug Windows programs in one application (e.g., Visual Basic) without the need to open additional programs (i.e., a program to create the program, a program that ex- ecutes the program, a program that debugs the program, etc.). In this chapter, we overview the Visual Basic IDE features and discuss how to create and execute a simple program.
When Visual Basic is loaded, the New Project dialog shown in Fig. 2.1 is displayed. The New Project dialog allows the programmer to choose what type of Visual Basic program to create. Standard EXE, which is highlighted by default, allows the programmer to cre- ate a standard executable (i.e., a program that uses the most common Visual Basic fea- tures). We use Standard EXE for the majority of examples and exercises in this book, although later in the book you will learn about some of the other types.
Each type listed in Fig. 2.1 describes a group of related files called a project. Collec- tively, the project files form a Visual Basic program. The project types listed in Fig. 2.1 are the “Visual” in Visual Basic, because they contain predefined features for designing Win- dows programs. The programmer can use or leverage these existing project types to create powerful Windows applications in a fraction of the time it would normally take to create the same applications in other programming languages.
The New Project dialog contains three tabs—New for creating a new project, Existing for opening an existing project and Recent for opening a project that has been previously loaded into the IDE. Note that the New Project dialog is displayed every time Visual Basic is executed unless the Don’t show this dialog in the future checkbox (in the lower-left portion of Fig. 2.1) is checked. The number and names of the types appearing in the window can differ depending on the version of Visual Basic. Figure 2.1 shows Visual Basic Enterprise Edition project types (you may be working with another version of Visual Basic 6 that shows fewer project types).
A project type is opened by either double-clicking its icon with the left mouse button or by single-clicking the icon with the left mouse button and pressing Open. Opening a project type closes the New Project dialog and loads the features associated with the selected project type into the IDE.
Pressing Cancel closes the New Project dialog without opening a project type. Pressing Help opens the on-line assistance. We refer to single-clicking with the left mouse button as selecting or clicking, and we refer to double-clicking with the left mouse button simply as double-clicking.
Figure 2.2 shows the IDE after Standard EXE is selected. The top of the IDE window (the title bar) displays Project1 - Microsoft Visual Basic [design]. The environment consists of various windows, a menu bar and a tool bar. The menu bar contains several menus (File, Edit, View, etc.), each of which we overview shortly. The tool bar contains several icons that provide quick access to commonly used features. We discuss several of these tool bar icons in this chapter and others later in the book.
A Standard EXE project contains the following windows:
• Project1 - Form1 (Form)
• Form Layout
• Project - Project1
• Toolbox
The Project - Form1 (Form) window contains a form named Form1, which is where the program’s Graphical User Interface (GUI) will be displayed. A GUI is the visual portion of the program (i.e., buttons, etc.)–this is where the user enters data (called inputs) to the program and where the program displays its results (called outputs) for the user to read. We refer to the Form1 window simply as “the form.”
Pressing Cancel closes the New Project dialog without opening a project type. Pressing Help opens the on-line assistance. We refer to single-clicking with the left mouse button as selecting or clicking, and we refer to double-clicking with the left mouse button simply as double-clicking.
Figure 2.2 shows the IDE after Standard EXE is selected. The top of the IDE window (the title bar) displays Project1 - Microsoft Visual Basic [design]. The environment consists of various windows, a menu bar and a tool bar. The menu bar contains several menus (File, Edit, View, etc.), each of which we overview shortly. The tool bar contains several icons that provide quick access to commonly used features. We discuss several of these tool bar icons in this chapter and others later in the book.
A Standard EXE project contains the following windows:
• Project1 - Form1 (Form)
• Form Layout
• Project - Project1
• Toolbox
The Project - Form1 (Form) window contains a form named Form1, which is where the program’s Graphical User Interface (GUI) will be displayed. A GUI is the visual portion of the program (i.e., buttons, etc.)–this is where the user enters data (called inputs) to the program and where the program displays its results (called outputs) for the user to read. We refer to the Form1 window simply as “the form.”
2 IDE with a Standard EXE project open.
The Form Layout window enables the user to specify the form’s position on the screen when the program is executed.
The Properties - Form1 window displays form attributes or properties (i.e., color, font style, size, etc.). The Project - Project1 window groups the project’s files by type.
The toolbox contains controls for customizing the GUI (i.e., the form). Controls are GUI components such as buttons and checkboxes. We discuss a simple example at the end of this chapter that customizes a form with a control from the toolbox. We discuss toolbox controls throughout the book, especially in Chapters 10 and 11.
In the remainder of this chapter, we use these windows to create, manage and execute our first Visual Basic program.
The window titled Project - Project1 (Fig. 2.3) is called the Project Explorer and con- tains the project files. We refer to the Project Explorer window simply as the Project window.
The Project window’s tool bar contains three buttons, namely View Code, View Object and Toggle Folders. When pressed, the View Code button displays a window for writing Visual Basic code. Writing code is the main subject of this book. View Object, when pressed, displays the form. Double-clicking Form1 (Form1) also displays the form. Both View Code and View Object are initially disabled (i.e., the buttons appear gray and
2 IDE with a Standard EXE project open.
The Form Layout window enables the user to specify the form’s position on the screen when the program is executed.
The Properties - Form1 window displays form attributes or properties (i.e., color, font style, size, etc.). The Project - Project1 window groups the project’s files by type.
The toolbox contains controls for customizing the GUI (i.e., the form). Controls are GUI components such as buttons and checkboxes. We discuss a simple example at the end of this chapter that customizes a form with a control from the toolbox. We discuss toolbox controls throughout the book, especially in Chapters 10 and 11.
In the remainder of this chapter, we use these windows to create, manage and execute our first Visual Basic program.
pressing them has no effect) unless Form1 (Form1) is selected (i.e., highlighted) as it is in Fig. 2.3. Figure 2.4 shows both the View Code and View Object buttons disabled. The Toggle Folders button toggles (i.e., alternately hides or shows) the Forms folder. When shown as in Fig. 2.3, the folder is visible, and when hidden as in Fig. 2.4, the folder is invis- ible. The Forms folder contains a listing of all forms in the current project. Early in the book our projects will have only one form.
Later in this chapter we will save projects and forms with more meaningful names. The current names Project1, Form1, etc. are default names provided by Visual Basic to help you get started. Visual Basic does many things automatically to minimize the amount of work you must do to create applications. In this regard, Visual Basic is the world’s most popular RAD (Rapid Applications Development) programming language. The Project window becomes an important project management tool as projects become more complex (i.e., contain more forms and other support files).
The toolbox (Fig. 2.5) contains controls used to customize forms. Controls are prepackaged components that you reuse instead of writing them yourself–this helps you write programs faster. In this chapter, we overview the toolbox controls and in later chapters we discuss these controls in greater detail. Notice the box named Data displayed at the bottom of Fig.
2.2 when the mouse pointer (i.e., the white arrow) rests on the Data control. These boxed descriptions, called tool tips, are displayed by Visual Basic to tell you what each icon means. Tool tips are also displayed for many IDE features besides the toolbox. Figure 2.6 summarizes the toolbox controls.