430 likes | 724 Views
2. Welcome Application Introducing the Visual Basic 2008 Express Edition IDE. Outline. 2.1 Test-Driving the Welcome Application 2.2 Overview of the Visual Basic 2008 Express Edition IDE 2.3 Creating a Project for the Welcome Application 2.4 Menu Bar and Toolbar
E N D
2 • Welcome Application • Introducing the Visual Basic2008 Express Edition IDE
Outline • 2.1Test-Driving the Welcome Application • 2.2Overview of the Visual Basic 2008 Express Edition IDE • 2.3 Creating a Project for the Welcome Application • 2.4 Menu Bar and Toolbar • 2.5 Visual Basic 2008 Express Edition IDE Windows • 2.6 Auto-Hide • 2.7 Using Help • 2.8 Saving and Closing Projects in Visual Basic
In this tutorial you will learn: Navigate Visual Studio 2008’s Start Page. Create a Visual Basic project. Use the IDE’s menus and toolbars. Manipulate windows in the Visual Basic 2008 Express Edition IDE. Use the auto-hide feature. Use the Visual Basic 2008 Express Edition IDE’s help features. Close a Visual Basic project. Objectives
Introduction • Visual Studio® 2008 is Microsoft’s integrated development environment (IDE) for creating, running and debugging applications. • The IDE allows you to create applications by dragging and dropping existing building blocks into place. • This technique is called visual programming.
2.1 Test-Driving the Welcome Application • A software company (Deitel & Associates) has asked you to develop a Visual Basic application that displays the message “Welcome to Visual Basic 2008!” and a picture of the company’s bug mascot.
Test-Driving the WelcomeApplication • Open Windows Explorer and navigate to the C:\Examples\Tutorial02 directory (Fig. 2.1). Contents ofC:\Examples\ Tutorial02 Figure 2.1| Contents of C:\Examples\Tutorial02.
Test-Driving the WelcomeApplication (Cont.) • Double click Welcome.exe (Fig. 2.1) to run the application (Fig. 2.2). Close box Figure 2.2|Welcome application executing. • Close your running application by clicking its close box,
2.2 Overview of the Visual Basic2008 Express Edition IDE • Many versions of Visual Studio are available. The examples in this book are based on the Microsoft Visual Basic 2008 Express Edition. • You can also purchase a full version of Visual Studio 2008, which includes support for other languages such as Visual C# and Visual C++. • To start the IDE, select Start>AllPrograms>MicrosoftVisualBasic2008ExpressEdition.
2.2 Overview of the Visual Basic2008 Express Edition IDE (Cont.) • Once the Express Edition begins execution, the Start Page displays (Fig. 2.3). Start Page Start Pagelinks EmptySolutionExplorer(no projects open) Figure 2.3|Start Page in Visual Basic 2008 Express Edition with an empty project list. • The StartPage contains a list of links to resources in theIDE and on the Internet.
2.2 Overview of the Visual Basic2008 Express Edition IDE (Cont.) • The StartPage links are organized into sections: • the RecentProjects section • the Getting Started section, which focuses on usingthe IDE for creating programs, learning Visual Basic, connecting to the Visual Basic developer community and providing development tools • and the VisualBasicExpressHeadlines and MSDN:VisualBasicExpressEdition sections, which provide links to information about programming in Visual Basic. • You can browse the MSDN (Microsoft Developer Network) online library at msdn2.microsoft.com/library.
2.2 Overview of the Visual Basic2008 Express Edition IDE (Cont.) • You can also browse the web from the IDE using the internalweb browser. • To request a web page, type its URL into the location bar (Fig. 2.4) (If the location bar is not already displayed, select View > Other Windows > Web Browser).
2.2 Overview of the Visual Basic2008 Express Edition IDE (Cont.) Selected tab forrequested web page Requested web page (URL in location-bar drop-down menu) Figure 2.4|Displaying a web page in the Visual Basic 2008 Express Edition IDE.
2.3 Creating a Project for theWelcome Application • Visual Basic organizes applications into projects and solutions. • A project is a group of related files, such as codeand images that might make up a program. • Solutions contain one or more projects.
Creating a Project for theWelcome Application • There are several ways to create a new project or open an existing one: • Select either File > New Project…, which creates a new project, or File > Open Project…, which opens an existing project. • From the Start Page, under the Recent Projects section, click the link Create: Project… or Open: Project…. • Click either the New ProjectButton (Fig.2.5) or the Open FileButton (Fig.2.5).
Creating a Project for theWelcome Application (Cont.) Title bar New Project button Open File button RecentProjects listing Figure 2.5|NewProject button and RecentProjects listing.
Creating a Project for theWelcome Application (Cont.) • Visual Basic provides templates for a variety of projects (Fig. 2.6). Templates are the project types you can createin Visual Basic. • Select Windows Forms Application. Default projectname (providedby Visual Basic) Figure 2.6|NewProject dialog.
Creating a Project for theWelcome Application (Cont.) • To rename the project, type Welcome in the Name:TextBox (Fig. 2.7). Then click OK. Visual BasicWindows Forms Application(selected) Updated project name Figure 2.7|NewProject dialog with updated project information.
Creating a Project for theWelcome Application (Cont.) • Save this project in your C:\SimplyVB2008 directory.To change the project’s location, select File > Save All (Fig. 2.8). Figure 2.8|Save Project dialog.
Creating a Project for theWelcome Application (Cont.) • Use the Browse… Button to locate your SimplyVB2008 directory (Fig. 2.9). After providing the project’s name and location in the Save Project dialog, click Save. SimplyVB2008directory(selected) Select FolderButton Figure 2.9|Project Locationdialog.
Creating a Project for theWelcome Application (Cont.) • The name of each open file is listed on a tab. • To view a file, click its tab (Fig. 2.10). Solution Explorer Tabs Menu bar Active tab Form (Windows application) titled Form1 Figure 2.10|Design view of the IDE. Properties window
Creating a Project for theWelcome Application (Cont.) • The content of the Form1.vb[Design] tab is the Windows Form Designer. • The Form (titled Form1) represents the main window of the Windows Forms application.
Creating a Project for theWelcome Application (Cont.) • GUI controls aid both in data entry by users and in formatting and presenting data outputs to users. • For example, Internet Explorer (Fig. 2.11) displays web pages requested by users.
Creating a Project for theWelcome Application (Cont.) Drop-down arrow Button (displaying an icon) ComboBox Menu (Help) Title bar (Label) Menu bar Toolbar Web site requestedby the user Figure 2.11|Internet Explorer window with GUI controls labeled.(Web site content courtesy of Deitel & Associates, Inc.)
2.4 Menu Bar and Toolbar • Menus contain commands for managing the IDE and for developing and executing applications. • The set of menus displayed (Fig. 2.12) depends on what you are currently doing in the IDE. Figure 2.12|Visual Basic 2008 IDE menu bar.
2.4 Menu Bar and Toolbar (Cont.) • Each menu has a group of related commands (also called menu items) that cause the IDE to perform specific actions (Fig. 2.13). Figure 2.13|Visual Basic IDE menu summary.
2.4 Menu Bar and Toolbar (Cont.) • You can access many common commands from the IDE toolbar (Fig. 2.14). • The toolbar contains icons that graphically represent commands. • To execute a command via the IDE toolbar, simplyclick its icon. Keyboard shortcuts Toolbar icon indicates a command to open a project Toolbar Down arrow indicates additional commandsare available Figure 2.14|IDE toolbar.
2.4 Menu Bar and Toolbar (Cont.) • Positioning the mouse pointer over an icon highlights it and, after a brief pause, displays a description of the icon called a tooltip (Fig. 2.15). Tooltip displayedwhen the mousepointer has restedon the icon for afew seconds Figure 2.15| Tooltip demonstration.
2.5 Visual Basic 2008 ExpressEdition IDE Windows • The IDE provides windows for accessing project filesand for customizing forms and controls. • You can access these windows by using the IDE toolbar icons (Fig. 2.16) or by selecting the window name, using the View menu. Properties icon Object Browser icon Solution Explorer icon Toolbox icon Figure 2.16| Toolbar icons for four Visual Basic IDE windows.
2.5 Visual Basic 2008 ExpressEdition IDE Windows (Cont.) Solution Explorer • The Solution Explorer window (Fig. 2.17) displays a list of the files in a project and the projects in a solution. • If the Solution Explorer window is not shown in the IDE, you can display it by selecting View > Solution Explorer. Propertieswindow icon Toolbar ShowAllFiles icon Project name Form file Figure 2.17|Solution Explorer with an open project.
2.5 Visual Basic 2008 ExpressEdition IDE Windows (Cont.) • Click the Show All Files icon (Fig. 2.18) to display all the files in the solution. Collapsed node (plus box expands node to showrelated files when clicked) Figure 2.18| Using the ShowAllFiles icon to display all the files in a solution. • For your single-project solution, Welcome is the only project. The Form file is named Form1.vb.
Navigating a Project with theSolution Explorer • After clicking the Show All Files icon, click the plus box to the left of the MyProject folder (Fig. 2.19) to expand the node. Expanded node (minus box) Figure 2.19| Expanded node.
Navigating a Project with theSolution Explorer (Cont.) • After clicking the Show All Files icon, click the plus box to the left of the MyProject folder (Fig. 2.19) to expand the node. Collapsed node (plus box) Figure 2.20|Collapsed node.
Navigating a Project with theSolution Explorer (Cont.) Group names Toolbox • Using visual programming, you can “drag and drop” controls onto the Form. • If the Toolbox is not visible, select View > Toolbox. • The Toolbox (Fig. 2.21) groups controls into categories. Controls Additional groupnames Figure 2.21|Toolbox displaying the contents of the Common Controls tab.
Navigating a Project with theSolution Explorer (Cont.) Properties Window • The Properties window (Fig. 2.22) displays an object’s attributes, such as its size, color and position. • The Properties window allows you to set object properties visually without writing code. • If the Properties window is not visible, selectView> PropertiesWindow (or press F4).
Navigating a Project with theSolution Explorer (Cont.) Object’sname(Form1) Object’s class (System.Windows.Forms.Form) Down arrow for selecting Formor control objects Component object box Categorized icon Toolbar Alphabetical icon Items that have beenchanged from their defaultvalues (by the user or by VisualStudio) are listed in bold Selected property Scrollbox Scrollbar Design category Description ofselected property Properties(left column) Property values(right column) Figure 2.22|Properties window displaying a Form’s properties.
Navigating a Project with theSolution Explorer (Cont.) • At the top of the Properties window is the component objectbox, which displays each object’s name and class type. • Icons on the toolbar sort the properties either alphabeticallyor categorically. • Each gray horizontal bar to the left of the scrollbar is a category that groups related properties. • The left column of the Properties window lists the object’s property names; the right column displays each property’s value. • Whenever you select a property, a description of the property displays at the bottom of the Properties window.
Using Auto-Hide • Auto-hide is enabled by clicking the window’s verticalpin icon. • The toolbar along one of the edges of the IDE containsone or more tabs, each of which identifies a hiddenwindow (Fig. 2.23) and displays the window whenclicked (Fig. 2.24). Mouse pointer over the tab for the Toolbox Tab for hidden window Title bar Horizontal pin icon (auto-hide enabled) Toolbox is displayedwhen the mouse pointeris placed on the tab forthe Toolbox Figure 2.23|Hidden-window tabs. Figure 2.24| Displaying a hidden window with auto-hide enabled.
Using Auto-Hide (Cont.) • Move the mouse pointer outside the Toolbox window’s area to hide the Toolbox (Fig. 2.25). Mouse pointer over the tab for the Toolbox(Toolboxwindow is hidden) Figure 2.25| Hiding the Toolbox by moving the mouse pointeroutside of the Toolbox’s area.
Using Auto-Hide (Cont.) • To disable auto-hide click the pin icon in the title bar. • When a window is “pinned down,” the pin icon is vertical (Fig. 2.26) • When auto-hide is enabled, the pin icon is horizontal. Vertical pin icon(auto-hide is disabled) Figure 2.26| Pin icon in vertical position.
Using Auto-Hide (Cont.) • Help provides a list of articles pertaining to the “current content.” • The help window also provides help topics, code samples and “Getting Started” information (Fig. 2.27). Figure 2.27|Help menu commands.
Using Auto-Hide (Cont.) • Visual Basic also provides context-sensitive help, which displays relevant help articles (Fig. 2.28). • To use context-sensitive help, click an item,then press the F1 key.
Using Auto-Hide (Cont.) Context-sensitivehelp window HowDo I Search Index Contents Toolbar Selected item(Windows form) Relevant helparticle Figure 2.28| Context-sensitive help window.
2.8 Saving and Closing Projectsin Visual Basic Once you’re finished with a project, you shouldsave the project’s files and close the project. • Before closing the project for the Welcomeapplication, you should save its files, ensuring that any changes made to the project are not lost. • Although you did not make any changes, save your project files by selecting File>Save All. • Select File>CloseProject.