Chapter 03 - Program Coding and Design
Upcoming SlideShare
Loading in...5
×
 

Chapter 03 - Program Coding and Design

on

  • 1,485 views

In this chaper we will learn how to change the BackColor property of an object ...

In this chaper we will learn how to change the BackColor property of an object
Understand Visual Basic 2010 code statement formatsand see how IntelliSense can be used to enter code statements.We will discuss the Visual Basic programming languge syntax and write coding statements. We will also see how to correct coding errors in Visual Basic 2010.
Correct errors in Visual Basic 2010 code. We will learn how to print code and how to prepare an Event Planning Document.

Statistics

Views

Total Views
1,485
Views on SlideShare
1,485
Embed Views
0

Actions

Likes
0
Downloads
78
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Chapter 03 - Program Coding and Design Chapter 03 - Program Coding and Design Presentation Transcript

  • Microsoft Visual Basic 2010CHAPTER THREE Program Design and Coding
  • 3 Objectives ►Change the BackColor property of an object ►Understand Visual Basic 2010 code statement formats ►Use IntelliSense to enter Visual Basic 2010 code statements ►Correct errors in Visual Basic 2010 code ►Write code for an object ►Print code ►Prepare an Event Planning DocumentChapter 3: Program Design and Coding 2
  • 3 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 listChapter 3: Program Design and Coding 3
  • 3 BackColor PropertyChapter 3: Program Design and Coding 4
  • 3 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 listChapter 3: Program Design and Coding 5
  • 3 Sizing an ImageChapter 3: Program Design and Coding 6
  • 3 Running a Program ►Point to the Start Debugging button on the Standard toolbar ►Click the Start Debugging button on the Standard toolbarChapter 3: Program Design and Coding 7
  • 3 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 objectChapter 3: Program Design and Coding 8
  • 3 Entering Visual Basic Code for Event HandlingChapter 3: Program Design and Coding 9
  • 3 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 objectChapter 3: Program Design and Coding 10
  • 3 General Format of a Visual Basic StatementChapter 3: Program Design and Coding 11
  • 3 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 typedChapter 3: Program Design and Coding 12
  • 3 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 keyboardChapter 3: Program Design and Coding 13
  • 3 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 keyChapter 3: Program Design and Coding 14
  • 3 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 keyChapter 3: Program Design and Coding 15
  • 3 Comments in Program StatementsChapter 3: Program Design and Coding 16
  • 3 Same Line CommentsChapter 3: Program Design and Coding 17
  • 3 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 keyChapter 3: Program Design and Coding 18
  • 3 Introductory CommentsChapter 3: Program Design and Coding 19
  • 3 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 programChapter 3: Program Design and Coding 20
  • 3 Correcting Errors in CodeChapter 3: Program Design and Coding 21
  • 3 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 windowChapter 3: Program Design and Coding 22
  • 3 Correcting Errors in CodeChapter 3: Program Design and Coding 23
  • 3 Additional Click Events ►On the frmHotelRoomSelection.vb [Design] tabbed page, double-click the Exit Window Button objectChapter 3: Program Design and Coding 24
  • 3 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 keyChapter 3: Program Design and Coding 25
  • 3 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 codeChapter 3: Program Design and Coding 26
  • 3 Event Planning DocumentChapter 3: Program Design and Coding 27
  • 3 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 logicChapter 3: Program Design and Coding 28
  • Microsoft Visual Basic 2010CHAPTER THREE COMPLETE Program Design and Coding