SlideShare uma empresa Scribd logo
1 de 49
CHAPTER THREE Program Design and Coding
Chapter 3: Program Design and Coding 2 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
Chapter 3: Program Design and Coding 3 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
Chapter 3: Program Design and Coding 4 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
Chapter 3: Program Design and Coding 5 Objectives Correct errors in Visual Basic 2010 code Write code to use the Close() procedure Print code Prepare an Event Planning Document
Chapter 3: Program Design and Coding 6 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
Chapter 3: Program Design and Coding 7 BackColor Property
Chapter 3: Program Design and Coding 8 Locating and Saving an Image from the World Wide Web Open your Internet browser. Then, enter scsite.com/vb2010/ch3/imagesin 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
Chapter 3: Program Design and Coding 9 Locating and Saving an Image from the World Wide Web
Chapter 3: Program Design and Coding 10 Importing the Image into the Program Resources Folder With Visual Studio 2010 and the Hotel Room Selection Visual Basic program open, select the picStandardRoomPictureBox 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
Chapter 3: Program Design and Coding 11 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
Chapter 3: Program Design and Coding 12 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
Chapter 3: Program Design and Coding 13 Sizing an Image
Chapter 3: Program Design and Coding 14 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
Chapter 3: Program Design and Coding 15 Visible Property
Chapter 3: Program Design and Coding 16 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
Chapter 3: Program Design and Coding 17 Enabled Property
Chapter 3: Program Design and Coding 18 Running a Program Point to the Start Debugging button on the Standard toolbar Click the Start Debugging button on the Standard toolbar
Chapter 3: Program Design and Coding 19 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
Chapter 3: Program Design and Coding 20 Entering Visual Basic Code for Event Handling
Chapter 3: Program Design and Coding 21 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
Chapter 3: Program Design and Coding 22 General Format of a Visual Basic Statement
Chapter 3: Program Design and Coding 23 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
Chapter 3: Program Design and Coding 24 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 picfollowed by a period To identify the correct entry, type the first letters of the entry until the entry is selected. In this case, type son 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
Chapter 3: Program Design and Coding 25 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
Chapter 3: Program Design and Coding 26 Entering a Visual Basic Statement
Chapter 3: Program Design and Coding 27 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 picon your keyboard Type dto 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
Chapter 3: Program Design and Coding 28 Setting the Visible Property to False
Chapter 3: Program Design and Coding 29 Enabled Property Type btnto display the IntelliSense list Type seuntil 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
Chapter 3: Program Design and Coding 30 Enabled Property
Chapter 3: Program Design and Coding 31 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
Chapter 3: Program Design and Coding 32 Comments in Program Statements
Chapter 3: Program Design and Coding 33 Same Line Comments
Chapter 3: Program Design and Coding 34 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
Chapter 3: Program Design and Coding 35 Introductory Comments
Chapter 3: Program Design and Coding 36 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
Correcting Errors in Code Chapter 3: Program Design and Coding 37
Chapter 3: Program Design and Coding 38 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
Chapter 3: Program Design and Coding 39 Correcting Errors in Code
Chapter 3: Program Design and Coding 40 Additional Click Events On the frmHotelRoomSelection.vb [Design] tabbed page, double-click the Exit Window Button object
Chapter 3: Program Design and Coding 41 Close Procedure With the insertion point positioned as shown in Figure 3-64 on page 154, type cloto highlight Close in the IntelliSense list Press the ENTER key
Chapter 3: Program Design and Coding 42 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
Chapter 3: Program Design and Coding 43 Event Planning Document
Chapter 3: Program Design and Coding 44 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
Chapter 3: Program Design and Coding 45 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
Chapter 3: Program Design and Coding 46 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
Chapter 3: Program Design and Coding 47 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
Chapter 3: Program Design and Coding 48 Summary Correct errors in Visual Basic 2010 code Write code to use the Close() procedure Print code Prepare an Event Planning Document
CHAPTER THREE COMPLETE Program Design and Coding

Mais conteúdo relacionado

Mais procurados

Chapter 03 - Program Coding and Design
Chapter 03 - Program Coding and DesignChapter 03 - Program Coding and Design
Chapter 03 - Program Coding and Designpatf719
 
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007ITVAMP, LLC
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesSami Mut
 
Creating a data report in visual basic 6
Creating a data report in visual basic 6Creating a data report in visual basic 6
Creating a data report in visual basic 6mrgulshansharma
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computersimran153
 
Adobe Illustrator CS5 Part 2 : Vector Graphic Effects
Adobe Illustrator CS5 Part 2 : Vector Graphic EffectsAdobe Illustrator CS5 Part 2 : Vector Graphic Effects
Adobe Illustrator CS5 Part 2 : Vector Graphic Effectscsula its training
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowTan Ps
 
Open Office Calc : Lesson 06
Open Office Calc : Lesson 06Open Office Calc : Lesson 06
Open Office Calc : Lesson 06thinkict
 

Mais procurados (14)

Chapter 03 - Program Coding and Design
Chapter 03 - Program Coding and DesignChapter 03 - Program Coding and Design
Chapter 03 - Program Coding and Design
 
Chapter03 Ppt
Chapter03 PptChapter03 Ppt
Chapter03 Ppt
 
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
Microsoft Project 2003 Configuration Training Level 2 Itvamp 2007
 
Excel chapter-7
Excel chapter-7Excel chapter-7
Excel chapter-7
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slides
 
Creating a data report in visual basic 6
Creating a data report in visual basic 6Creating a data report in visual basic 6
Creating a data report in visual basic 6
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 
Adobe Illustrator CS5 Part 2 : Vector Graphic Effects
Adobe Illustrator CS5 Part 2 : Vector Graphic EffectsAdobe Illustrator CS5 Part 2 : Vector Graphic Effects
Adobe Illustrator CS5 Part 2 : Vector Graphic Effects
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure below
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
 
Open Office Calc : Lesson 06
Open Office Calc : Lesson 06Open Office Calc : Lesson 06
Open Office Calc : Lesson 06
 
Visual basic
Visual basicVisual basic
Visual basic
 
Ms Access
Ms AccessMs Access
Ms Access
 
2 front panel
2  front panel2  front panel
2 front panel
 

Destaque

Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming francopw
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
Chapter 01
Chapter 01Chapter 01
Chapter 01llmeade
 
14b. Computer Systems Extra Output
14b. Computer Systems   Extra Output14b. Computer Systems   Extra Output
14b. Computer Systems Extra OutputNew Era University
 
13a.Computer Systems Extra Input
13a.Computer Systems   Extra Input13a.Computer Systems   Extra Input
13a.Computer Systems Extra InputNew Era University
 
Intro to MATLAB GUI
Intro to MATLAB GUIIntro to MATLAB GUI
Intro to MATLAB GUIAsjad Ali
 
27. Computer Applications Business And Engineering
27. Computer Applications   Business And Engineering27. Computer Applications   Business And Engineering
27. Computer Applications Business And EngineeringNew Era University
 
12. Computer Systems Hardware 2
12. Computer Systems   Hardware 212. Computer Systems   Hardware 2
12. Computer Systems Hardware 2New Era University
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1New Era University
 
Vtoc, Use Case, Activity Diagram
Vtoc, Use Case, Activity DiagramVtoc, Use Case, Activity Diagram
Vtoc, Use Case, Activity DiagramNew Era University
 
16. Computer Systems Basic Software 2
16. Computer Systems   Basic Software 216. Computer Systems   Basic Software 2
16. Computer Systems Basic Software 2New Era University
 
Basic components of computer system
Basic components  of computer systemBasic components  of computer system
Basic components of computer systemTECHNOHABIT
 
Internal parts of a computer and their functions
Internal parts of a computer and their functionsInternal parts of a computer and their functions
Internal parts of a computer and their functionsEmily-scamell
 
Internal components of the computer
Internal components of the computerInternal components of the computer
Internal components of the computerDanielAtkinson96
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)pbarasia
 
Sample Narrative report for seminars
Sample Narrative report for seminarsSample Narrative report for seminars
Sample Narrative report for seminarsNew Era University
 
Introduction to Basic Computer Concepts Presentation
Introduction to Basic Computer Concepts PresentationIntroduction to Basic Computer Concepts Presentation
Introduction to Basic Computer Concepts PresentationAna Tan
 
Components of a computer system
Components of a computer systemComponents of a computer system
Components of a computer systemlistergc
 

Destaque (19)

Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
14b. Computer Systems Extra Output
14b. Computer Systems   Extra Output14b. Computer Systems   Extra Output
14b. Computer Systems Extra Output
 
13a.Computer Systems Extra Input
13a.Computer Systems   Extra Input13a.Computer Systems   Extra Input
13a.Computer Systems Extra Input
 
Intro to MATLAB GUI
Intro to MATLAB GUIIntro to MATLAB GUI
Intro to MATLAB GUI
 
27. Computer Applications Business And Engineering
27. Computer Applications   Business And Engineering27. Computer Applications   Business And Engineering
27. Computer Applications Business And Engineering
 
12. Computer Systems Hardware 2
12. Computer Systems   Hardware 212. Computer Systems   Hardware 2
12. Computer Systems Hardware 2
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1
 
Matlab GUI
Matlab GUIMatlab GUI
Matlab GUI
 
Vtoc, Use Case, Activity Diagram
Vtoc, Use Case, Activity DiagramVtoc, Use Case, Activity Diagram
Vtoc, Use Case, Activity Diagram
 
16. Computer Systems Basic Software 2
16. Computer Systems   Basic Software 216. Computer Systems   Basic Software 2
16. Computer Systems Basic Software 2
 
Basic components of computer system
Basic components  of computer systemBasic components  of computer system
Basic components of computer system
 
Internal parts of a computer and their functions
Internal parts of a computer and their functionsInternal parts of a computer and their functions
Internal parts of a computer and their functions
 
Internal components of the computer
Internal components of the computerInternal components of the computer
Internal components of the computer
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
 
Sample Narrative report for seminars
Sample Narrative report for seminarsSample Narrative report for seminars
Sample Narrative report for seminars
 
Introduction to Basic Computer Concepts Presentation
Introduction to Basic Computer Concepts PresentationIntroduction to Basic Computer Concepts Presentation
Introduction to Basic Computer Concepts Presentation
 
Components of a computer system
Components of a computer systemComponents of a computer system
Components of a computer system
 

Semelhante a Chapter 03

Chapter 02
Chapter 02Chapter 02
Chapter 02llmeade
 
Chapter 05 show
Chapter 05 showChapter 05 show
Chapter 05 showchda01008
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Jeanie Arnoco
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptNourhanTarek23
 
Visual basics Express Project
Visual basics Express ProjectVisual basics Express Project
Visual basics Express ProjectIftikhar Ahmed
 
Lect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptLect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptNourhanTarek23
 
Chapter2.ppt
Chapter2.pptChapter2.ppt
Chapter2.pptLalRatan
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinFormHock Leng PUAH
 
Chapter 02 - Program and Grapahical User Interface
Chapter 02 - Program and Grapahical User InterfaceChapter 02 - Program and Grapahical User Interface
Chapter 02 - Program and Grapahical User Interfacepatf719
 
Csc153 chapter 03
Csc153 chapter 03Csc153 chapter 03
Csc153 chapter 03PCC
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editorputiadetiara
 
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptxhjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptxEliasPetros
 

Semelhante a Chapter 03 (20)

Chapter 02
Chapter 02Chapter 02
Chapter 02
 
Ppt lesson 03
Ppt lesson 03Ppt lesson 03
Ppt lesson 03
 
Chapter 05 show
Chapter 05 showChapter 05 show
Chapter 05 show
 
Introduction
IntroductionIntroduction
Introduction
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.ppt
 
Visual basics Express Project
Visual basics Express ProjectVisual basics Express Project
Visual basics Express Project
 
Lect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptLect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.ppt
 
Chapter2.ppt
Chapter2.pptChapter2.ppt
Chapter2.ppt
 
Spf chapter 03 WinForm
Spf chapter 03 WinFormSpf chapter 03 WinForm
Spf chapter 03 WinForm
 
Chapter 02 - Program and Grapahical User Interface
Chapter 02 - Program and Grapahical User InterfaceChapter 02 - Program and Grapahical User Interface
Chapter 02 - Program and Grapahical User Interface
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
SPF WinForm Programs
SPF WinForm ProgramsSPF WinForm Programs
SPF WinForm Programs
 
Chapter - 6.pptx
Chapter - 6.pptxChapter - 6.pptx
Chapter - 6.pptx
 
Csc153 chapter 03
Csc153 chapter 03Csc153 chapter 03
Csc153 chapter 03
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editor
 
Android development part 2
Android development part 2Android development part 2
Android development part 2
 
Android development part 2
Android development part 2Android development part 2
Android development part 2
 
Ch01
Ch01Ch01
Ch01
 
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptxhjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
 

Chapter 03

  • 1. CHAPTER THREE Program Design and Coding
  • 2. Chapter 3: Program Design and Coding 2 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 Coding 3 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
  • 4. Chapter 3: Program Design and Coding 4 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
  • 5. Chapter 3: Program Design and Coding 5 Objectives Correct errors in Visual Basic 2010 code Write code to use the Close() procedure Print code Prepare an Event Planning Document
  • 6. Chapter 3: Program Design and Coding 6 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
  • 7. Chapter 3: Program Design and Coding 7 BackColor Property
  • 8. Chapter 3: Program Design and Coding 8 Locating and Saving an Image from the World Wide Web Open your Internet browser. Then, enter scsite.com/vb2010/ch3/imagesin 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
  • 9. Chapter 3: Program Design and Coding 9 Locating and Saving an Image from the World Wide Web
  • 10. Chapter 3: Program Design and Coding 10 Importing the Image into the Program Resources Folder With Visual Studio 2010 and the Hotel Room Selection Visual Basic program open, select the picStandardRoomPictureBox 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
  • 11. Chapter 3: Program Design and Coding 11 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
  • 12. Chapter 3: Program Design and Coding 12 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
  • 13. Chapter 3: Program Design and Coding 13 Sizing an Image
  • 14. Chapter 3: Program Design and Coding 14 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
  • 15. Chapter 3: Program Design and Coding 15 Visible Property
  • 16. Chapter 3: Program Design and Coding 16 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
  • 17. Chapter 3: Program Design and Coding 17 Enabled Property
  • 18. Chapter 3: Program Design and Coding 18 Running a Program Point to the Start Debugging button on the Standard toolbar Click the Start Debugging button on the Standard toolbar
  • 19. Chapter 3: Program Design and Coding 19 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
  • 20. Chapter 3: Program Design and Coding 20 Entering Visual Basic Code for Event Handling
  • 21. Chapter 3: Program Design and Coding 21 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
  • 22. Chapter 3: Program Design and Coding 22 General Format of a Visual Basic Statement
  • 23. Chapter 3: Program Design and Coding 23 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
  • 24. Chapter 3: Program Design and Coding 24 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 picfollowed by a period To identify the correct entry, type the first letters of the entry until the entry is selected. In this case, type son 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
  • 25. Chapter 3: Program Design and Coding 25 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
  • 26. Chapter 3: Program Design and Coding 26 Entering a Visual Basic Statement
  • 27. Chapter 3: Program Design and Coding 27 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 picon your keyboard Type dto 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
  • 28. Chapter 3: Program Design and Coding 28 Setting the Visible Property to False
  • 29. Chapter 3: Program Design and Coding 29 Enabled Property Type btnto display the IntelliSense list Type seuntil 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
  • 30. Chapter 3: Program Design and Coding 30 Enabled Property
  • 31. Chapter 3: Program Design and Coding 31 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
  • 32. Chapter 3: Program Design and Coding 32 Comments in Program Statements
  • 33. Chapter 3: Program Design and Coding 33 Same Line Comments
  • 34. Chapter 3: Program Design and Coding 34 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
  • 35. Chapter 3: Program Design and Coding 35 Introductory Comments
  • 36. Chapter 3: Program Design and Coding 36 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
  • 37. Correcting Errors in Code Chapter 3: Program Design and Coding 37
  • 38. Chapter 3: Program Design and Coding 38 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
  • 39. Chapter 3: Program Design and Coding 39 Correcting Errors in Code
  • 40. Chapter 3: Program Design and Coding 40 Additional Click Events On the frmHotelRoomSelection.vb [Design] tabbed page, double-click the Exit Window Button object
  • 41. Chapter 3: Program Design and Coding 41 Close Procedure With the insertion point positioned as shown in Figure 3-64 on page 154, type cloto highlight Close in the IntelliSense list Press the ENTER key
  • 42. Chapter 3: Program Design and Coding 42 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
  • 43. Chapter 3: Program Design and Coding 43 Event Planning Document
  • 44. Chapter 3: Program Design and Coding 44 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
  • 45. Chapter 3: Program Design and Coding 45 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
  • 46. Chapter 3: Program Design and Coding 46 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
  • 47. Chapter 3: Program Design and Coding 47 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
  • 48. Chapter 3: Program Design and Coding 48 Summary Correct errors in Visual Basic 2010 code Write code to use the Close() procedure Print code Prepare an Event Planning Document
  • 49. CHAPTER THREE COMPLETE Program Design and Coding