Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.

Slides:



Advertisements
Similar presentations
Creating and Editing a Web Page Using Inline Styles
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Excel Web Feature Creating Static and Dynamic Web Pages Using Excel.
Microsoft Office 2007 Excel Web Feature Creating Web Pages Using Excel.
Word Lesson 1 Microsoft Word Basics
Microsoft Office 2007 Word Web Feature Creating Web Pages Using Word.
Microsoft Office 2007 PowerPoint Web Feature Creating Web Pages Using PowerPoint.
© by Pearson Education, Inc. All Rights Reserved. continued …
Copyright 2003, Paradigm Publishing Inc. CHAPTER 1 BACKNEXTEND 1-1 LINKS TO OBJECTIVES Worksheet Elements Create, Save, and Print a Worksheet Create, Save,
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Word Project 1 Creating and Editing a Word Document.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Creating, Formatting, and Editing a Word Document with a Picture
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Word Web Feature Creating Web Pages Using Word.
Key Applications Module Lesson 12 — Word Essentials
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Word 2010 Chapter 1 Creating, Formatting, and Editing a Word Document with Pictures.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2005 CHAPTER 5 Mobile Applications Using Decision Structures.
Pasewark & Pasewark 1 Word Lesson 1 Word Basics Microsoft Office 2007: Introductory.
IE 411/511: Visual Programming for Industrial Applications
Creating and Editing a Web Page Project 2. Project Objectives Project 2: Creating and Editing a Web Page 2 Identify elements of a Web page Start Notepad.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Productivity Programs Common Features and Commands.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 1 1 Microsoft Office FrontPage 2003 Tutorial 1 – Creating a Web Site.
Dreamweaver CS4 Concepts and Techniques Chapter 2 Adding Web Pages, Links, and Images.
Chapter 1 Creating a Dreamweaver Web Page and Local Site
Microsoft Publisher 2010 Chapter 7 Advanced Formatting and Merging Publications with Data.
Visual Basic.NET BASICS Lesson 3 Events and Code.
Copyright 2002, Paradigm Publishing Inc. CHAPTER 1 BACKNEXTEND 1-1 LINKS TO OBJECTIVES Worksheet Elements Worksheet Elements Worksheet Area Elements Worksheet.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Microsoft Publisher 2010 Chapter 1 Creating a Flyer.
HTML Concepts and Techniques Fifth Edition Chapter 4 Creating Tables in a Web Site.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
HTML Concepts and Techniques Fifth Edition Chapter 3 Creating Web Pages with Links, Images, and Formatted Text.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Creating and Editing a Web Page
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Creating and Editing a Web Page Using Inline Styles
1 Word Lesson 1 Microsoft Word Basics Microsoft Office 2010 Introductory Pasewark & Pasewark.
Microsoft Office 2007: Introductory Pasewark & Pasewark 1.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
XP New Perspectives on Creating Web Pages With Word Tutorial 1 1 Creating Web Pages With Word Tutorial 1.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
Key Applications Module Lesson 12 — Word Essentials Computer Literacy BASICS.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Word Lesson 1 Microsoft Word Basics
Excel Tutorial 8 Developing an Excel Application
Word Lesson 1 Word Basics
Program and Graphical User Interface Design
Variables and Arithmetic Operations
Microsoft Excel 2007 – Level 1
Presentation transcript:

Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding

3 Chapter 3: Program Design and Coding2 Objectives ► Change the BackColor property of an object ► Add images to a PictureBox object ► Locate and save an image from the World Wide Web ► Import an image into the Program Resources folder ► Size an image

3 Chapter 3: Program Design and Coding3 Objectives ► Set the Visible property in the Properties window ► Set the Enabled property in the Properties window ► Run a Visual Basic 2010 program ► Enter Visual Basic 2010 code ► Understand Visual Basic 2010 code statement formats

3 Chapter 3: Program Design and Coding4 Objectives ► Use IntelliSense to enter Visual Basic 2010 code statements ► Using code, set the Visible property of an object ► Using code, set the Enabled property of an object ► Enter comments in Visual Basic 2010 code

3 Chapter 3: Program Design and Coding5 Objectives ► Correct errors in Visual Basic 2010 code ► Write code to use the Close() procedure ► Print code ► Prepare an Event Planning Document

3 Preview the Chapter Project Chapter 3: Program Design and Coding6

3 7 BackColor Property ► Click the Windows Form object to select it ► If necessary, scroll in the Properties window until the BackColor property is displayed, and then click the right column of the BackColor property ► Click the BackColor arrow. Then, if necessary, click the Web tab to display the Web tabbed page ► Scroll to display the color you wish to apply ► Click the color you wish to apply on the color list

3 Chapter 3: Program Design and Coding8 BackColor Property

3 Chapter 3: Program Design and Coding9

3 10 Locating and Saving an Image from the World Wide Web ► Open your Internet browser. Then, enter scsite.com/vb2010/ch3/images in the Address box and press the ENTER key ► Locate the StandardRoom.jpg image and then right- click the image ► Click Save Picture As on the shortcut menu ► Identify the drive and folder where the image will be stored. Enter the image file name, StandardRoom, in the File name text box ► Click the Save button in the Save Picture dialog box to save the image in the selected location

3 Chapter 3: Program Design and Coding11 Locating and Saving an Image from the World Wide Web

3 Chapter 3: Program Design and Coding12

3 Chapter 3: Program Design and Coding13 Importing the Image into the Program Resources Folder ► With Visual Studio 2010 and the Hotel Room Selection Visual Basic program open, select the picStandardRoom PictureBox object by clicking it. Scroll in the PictureBox Properties window until the Image property is visible. Click the Image property name in the left list in the Properties window ► Click the Ellipsis button in the right column of the Image property ► Click the Import button in the Select Resource dialog box. Then, using the features of the Open dialog box, locate the file you want to import into the program

3 Chapter 3: Program Design and Coding14 Importing the Image into the Program Resources Folder ► Click the Open button in the Open dialog box ► With the StandardRoom file name selected in the Project resource file list, click the OK button in the Select Resource dialog box

3 Importing the Image into the Program Resources Folder Chapter 3: Program Design and Coding15

3 Chapter 3: Program Design and Coding16 Sizing an Image ► With the PictureBox object containing the StandardRoom image selected, scroll in the picStandardRoom Properties window until you see the SizeMode property. Click the SizeMode property name in the left column and then click the SizeMode arrow in the right column of the SizeMode property ► Click StretchImage in the SizeMode list

3 Chapter 3: Program Design and Coding17 Sizing an Image

3 Chapter 3: Program Design and Coding18

3 Chapter 3: Program Design and Coding19 Visible Property ► If necessary, select the picStandardRoom PictureBox object. Scroll in the Properties window until the Visible property is displayed. Click the Visible property name in the left column, and then click the Visible arrow in the right column of the Visible property ► Click False on the Visible property list

3 Chapter 3: Program Design and Coding20 Visible Property

3 Chapter 3: Program Design and Coding21

3 Chapter 3: Program Design and Coding22 Enabled Property ► Select the btnSelectRoom object. Scroll in the Properties window until the Enabled property is displayed. Click the Enabled property name in the left column, and then click the Enabled arrow in the right column of the Enabled property ► Click False on the Enabled property list

3 Chapter 3: Program Design and Coding23 Enabled Property

3 Chapter 3: Program Design and Coding24

3 Chapter 3: Program Design and Coding25 Running a Program ► Point to the Start Debugging button on the Standard toolbar ► Click the Start Debugging button on the Standard toolbar

3 Running a Program Chapter 3: Program Design and Coding26

3 Chapter 3: Program Design and Coding27 Entering Visual Basic Code for Event Handling ► With Visual Studio 2010 and the Hotel Room Selection program open and the frmHotelRoomSelection.vb [Design] tabbed window visible, point to the Standard Room Button object in the Windows Form object ► Double-click the Standard Room Button object

3 Chapter 3: Program Design and Coding28 Entering Visual Basic Code for Event Handling

3 Chapter 3: Program Design and Coding29

3 Chapter 3: Program Design and Coding30 Visual Basic 2010 Coding Statements ► The Visual Basic syntax specifies how each statement must be written ► When the user clicks the Standard Room button while the program is running, the standard room image should be displayed in the picStandardRoom PictureBox object

3 Chapter 3: Program Design and Coding31 General Format of a Visual Basic Statement

3 Chapter 3: Program Design and Coding32 IntelliSense ► IntelliSense displays all allowable entries you can make in a Visual Basic statement each time a dot (period), equal sign, or other special character required for the statement is typed

3 Chapter 3: Program Design and Coding33 Entering a Visual Basic Statement ► With the code window open and the insertion point positioned as shown in Figure 3-25 on page 131, type pic followed by a period ► To identify the correct entry, type the first letters of the entry until the entry is selected. In this case, type s on your keyboard ► When IntelliSense highlights the correct object name, press the key on the keyboard corresponding to the entry that is to follow the object name. In this case, press the PERIOD key ► As with the object name in the second step, the next step is to enter one or more characters until IntelliSense highlights the desired property in the list. Type the letter, v on your keyboard

3 Chapter 3: Program Design and Coding34 Entering a Visual Basic Statement ► Press the key for the character that is to follow the property name. In this case, press the SPACEBAR on the keyboard ► Press the EQUAL SIGN key on the keyboard and then press the SPACEBAR. On the IntelliSense list, click the Common tab to display the most common results ► Type t on the keyboard ► Press the key for the character that is to follow the True entry. In this case, press the ENTER key

3 Chapter 3: Program Design and Coding35 Entering a Visual Basic Statement

3 Chapter 3: Program Design and Coding36

3 Chapter 3: Program Design and Coding37 Setting the Visible Property to False ► With the insertion point on the second line of the code editing window for the Click event of the Standard Room button, type pic on your keyboard ► Type d to highlight the picDeluxeRoom entry in the IntelliSense list ► Press the key on the keyboard for the character that is to follow the object name. In this case, press the PERIOD key ► Press the SPACEBAR, press the EQUAL SIGN key, and then press the SPACEBAR ► Type f and then press the ENTER key

3 Chapter 3: Program Design and Coding38 Setting the Visible Property to False

3 Chapter 3: Program Design and Coding39

3 Chapter 3: Program Design and Coding40 Enabled Property ► Type btn to display the IntelliSense list ► Type se until IntelliSense highlights the btnSelectRoom entry in the list ► Type a period, type e, press the SPACEBAR, press the EQUAL SIGN key, press the SPACEBAR again, and then type t to select True in the IntelliSense list ► Press the ENTER key to enter the completed statement and place the insertion point on the next line

3 Chapter 3: Program Design and Coding41 Enabled Property

3 Chapter 3: Program Design and Coding42

3 Chapter 3: Program Design and Coding43 Comments in Program Statements ► To insert a blank line following the event code generated by Visual Studio that begins with the word, Private, click anywhere in that line and then press the END key on your keyboard ► Press the ENTER key ► Type the first line of the comments, beginning with an apostrophe, as shown in Figure 3-46 on page 143, and then press the ENTER key

3 Chapter 3: Program Design and Coding44 Comments in Program Statements

3 Chapter 3: Program Design and Coding45

3 Chapter 3: Program Design and Coding46 Same Line Comments

3 Chapter 3: Program Design and Coding47 Introductory Comments ► Click to the left of the word, Public, on line 1 in the program to place the insertion point on that line ► Press the ENTER key one time, and then press the UP ARROW key one time ► Type an apostrophe, a space, the text, Program Name: and then press the TAB key one time ► Type Hotel Room Selection as the name of the program. Then, press the ENTER key

3 Chapter 3: Program Design and Coding48 Introductory Comments

3 Chapter 3: Program Design and Coding49

3 Chapter 3: Program Design and Coding50 Correcting Errors in Code ► Using IntelliSense reduces the likelihood of coding errors considerably, although it is still possible to code an error One possible error may be forgetting an apostrophe in a comment statement ► A build errors message means the Visual Basic compiler detected a coding error in the program

3 Correcting Errors in Code Chapter 3: Program Design and Coding51

3 Chapter 3: Program Design and Coding52 Correcting Errors in Code ► Click the No button in the Microsoft Visual Studio dialog box that informs you of a build error ► Double-click anywhere on the error line ► Click in the leftmost column on line 7 to place the insertion point at that location ► Type an apostrophe ► Click anywhere in the code editing window

3 Chapter 3: Program Design and Coding53 Correcting Errors in Code

3 Chapter 3: Program Design and Coding54

3 Chapter 3: Program Design and Coding55 Additional Click Events ► On the frmHotelRoomSelection.vb [Design] tabbed page, double-click the Exit Window Button object

3 Additional Click Events Chapter 3: Program Design and Coding56

3 Chapter 3: Program Design and Coding57 Close Procedure ► With the insertion point positioned as shown in Figure 3-64 on page 154, type clo to highlight Close in the IntelliSense list ► Press the ENTER key

3 Close Procedure Chapter 3: Program Design and Coding58

3 Chapter 3: Program Design and Coding59 Printing Code ► Click File on the menu bar to display the File menu ► Click Print on the File menu to display the Print dialog box ► Ensure that a check mark appears in the Include line numbers check box if you want line numbers on your printout. Most developers prefer line numbers on printouts ► Make any other selections you find necessary in the Print dialog box ► Click the OK button in the Print dialog box to print the code

3 Chapter 3: Program Design and Coding60 Event Planning Document

3 Chapter 3: Program Design and Coding61 Phase 4 – Code the Program ► After the events and tasks within the vents have been identified, the developer is ready to code the program Entering Visual Basic statements to accomplish the tasks specified on the event planning document ► Developer enters the code and implements the logic

3 Chapter 3: Program Design and Coding62 Summary ► Change the BackColor property of an object ► Add images to a PictureBox object ► Locate and save an image from the World Wide Web ► Import an image into the Program Resources folder ► Size an image

3 Chapter 3: Program Design and Coding63 Summary ► Set the Visible property in the Properties window ► Set the Enabled property in the Properties window ► Run a Visual Basic 2010 program ► Enter Visual Basic 2010 code ► Understand Visual Basic 2010 code statement formats

3 Chapter 3: Program Design and Coding64 Summary ► Use IntelliSense to enter Visual Basic 2010 code statements ► Using code, set the Visible property of an object ► Using code, set the Enabled property of an object ► Enter comments in Visual Basic 2010 code

3 Chapter 3: Program Design and Coding65 Summary ► Correct errors in Visual Basic 2010 code ► Write code to use the Close() procedure ► Print code ► Prepare an Event Planning Document

Microsoft Visual Basic 2010 CHAPTER THREE COMPLETE Program Design and Coding