Programming with Microsoft Visual Basic 2010 5 th Edition

advertisement
Programming with
Microsoft Visual Basic 2010
5th Edition
Chapter Two
Designing Applications
Previewing the Playtime Cellular
Application
 Playtime Cellular application
 Allows salespeople to enter customer’s name, address, and
number of blue and pink phones ordered
 Calculates and displays total number of phones ordered and the
total price of the order
2
Programming with Microsoft Visual Basic 2010, 5th Edition
Previewing the Playtime Cellular
Application (cont’d.)
Figure 2-2 Completed order
3
Programming with Microsoft Visual Basic 2010, 5th Edition
Lesson A Objectives
After studying Lesson A, you should be able to:
 Plan an object-oriented application in Visual Basic 2010
 Complete a TOE (Task, Object, Event) chart
 Follow the Windows standards regarding the layout and
labeling of controls
4 Programming with Microsoft Visual Basic 2010, 5th Edition
Creating an Object-Oriented Application
 Developing an application is like building a home
 Role of programmer is analogous to that of builder
 Bugs
 Problems that affect application functions
5
Programming with Microsoft Visual Basic 2010, 5th Edition
Creating an Object-Oriented Application
(cont’d.)
Figure 2-3 Processes used by a builder and a programmer
6
Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application
 Actively involve user in planning phase
 End product should closely match the user’s needs and wants
 TOE chart
 Used to record tasks, objects, and events required for the
application
7
Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
Figure 2-4 Steps for planning an OO application
8
Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
 Identifying the application’s tasks
 What information will the application need to display on the
screen and/or print on the printer?
 What information will the user need to enter into the user
interface?
 What information will the application need to calculate to
produce the desired result?
 How will the user end the application?
 Will previous information need to be cleared from the screen
before new information is entered?
9
Programming with Microsoft Visual Basic 2010, 5th Edition
Figure 2-6 Tasks entered in a TOE chart
10 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
 Identifying the objects
 Assign each task to an object in user interface
 Objects used here
 Label control, button control, text box
 Label control
 Displays information that user should not change
 Button control
 Performs an action immediately after a Click event
 Text box
 Provides an area for user to enter data
11 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
 Identifying the events
 Determine which event (if any) must occur for an object to
carry out its assigned task
 Text boxes and label controls
 No special event is needed
 btnCalc, btnClear, and btnExit buttons
 Perform assigned tasks when clicked
12 Programming with Microsoft Visual Basic 2010, 5th Edition
Figure 2-9 Completed TOE chart ordered by object
13 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
 Drawing a sketch of the user interface
 Follow Windows standards for designing the interface
 In Western countries, information flows either vertically or
horizontally
 Vertical arrangement: Information flows from top to bottom, with
essential information located in first column
 Horizontal arrangement: Information flows from left to right, with
essential information placed in first row
14 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
Figure 2-10 Vertical arrangement of the Playtime Cellular application
15 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
Figure 2-11 Horizontal arrangement of the Playtime Cellular application
16 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
 White space or containers may be used to group related
controls
 Containers: Objects used to group related controls
 Examples: GroupBox, Panel, TableLayoutPanel
 Label controls that display output should have meaningful
names
 Example: “Total Price” identifies lblTotalPrice label
 Identifying labels should end with colon (:)
 Example: “Total Price:”
17 Programming with Microsoft Visual Basic 2010, 5th Edition
Planning an Object-Oriented
Application (cont’d.)
 Sentence capitalization
 Only first letter in the first word is capitalized
 Use for identifying labels
 Book title capitalization
 Capitalize first letter of each word except articles,
conjunctions, and prepositions
 Use for button text
 Buttons should be aligned
 Also same height and width
 Group related controls close to each other
18 Programming with Microsoft Visual Basic 2010, 5th Edition
Lesson A Summary
 Steps to create an OO application
 Meet with client
 Plan application
 Identify needed tasks, objects, and events
 Identify information needed as input to produce desired result
 Build user interface
 Code application
 Test and debug application
 Assemble documentation
19 Programming with Microsoft Visual Basic 2010, 5th Edition
Download