Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clearly Visual Basic: Programming with Visual Basic 2008

Similar presentations


Presentation on theme: "Clearly Visual Basic: Programming with Visual Basic 2008"— Presentation transcript:

1 Clearly Visual Basic: Programming with Visual Basic 2008
Chapter 5 Do It Yourself Designing

2 Objectives Use a text box to get user input
Perform an action with a button control Code a control’s Click event procedure Stop an application using the Me.Close() instruction Clearly Visual Basic: Programming with Visual Basic 2008

3 Delegating the Work Figure 5-1 When designing interface for a problem
Shows Addison Smith problem’s output, input, and algorithm When designing interface for a problem Examine each step in the problem’s algorithm, along with its output and input items Assign meaningful names to each of the controls listed in Figure 5-2 Camel case Uppercase letters appear as “humps” in the name Clearly Visual Basic: Programming with Visual Basic 2008

4 Clearly Visual Basic: Programming with Visual Basic 2008

5 Clearly Visual Basic: Programming with Visual Basic 2008

6 Clearly Visual Basic: Programming with Visual Basic 2008

7 It is customary to show the results of a calculation as a ____.
Mini Quiz It is customary to show the results of a calculation as a ____. Using Hungarian Notation, which of the following is a good name for the city? cityTextBox TextBoxCity txtCity TxtCity The three-character ID for a button control name is ______. Page 78- Commission Calculator Program Create a new application program called Commission Calculator Project Change font property to Sego UI, 9pt and StartPosition to CenterScreen Change the forms Text Property to Commission Calculator Change the forms Name to: frmMain Clearly Visual Basic: Programming with Visual Basic 2008

8 Clearly Visual Basic: Programming with Visual Basic 2008

9 Delegating the Work (continued)
Sentence capitalization Capitalize only first letter in each word and in any words that are customarily capitalized Example: identifying labels Book title capitalization Capitalize first letter in each word, except for articles, conjunctions, and prepositions Example: button captions Clearly Visual Basic: Programming with Visual Basic 2008

10 Making the Interface More User-Friendly
Access key Allows user to select a menu using the Alt key in combination with a letter or number Not case sensitive Should be assigned to each control (in the interface) that can accept user input Allows user to work with interface even when mouse becomes inoperative Clearly Visual Basic: Programming with Visual Basic 2008

11 Clearly Visual Basic: Programming with Visual Basic 2008

12 Quick Access Keys- Driven by the ALT KEY
Clearly Visual Basic: Programming with Visual Basic 2008

13 Clearly Visual Basic: Programming with Visual Basic 2008

14 Making the Interface More User-Friendly (continued)
Tab order Determined by number stored in each control’s TabIndex property When interface is first created TabIndex values reflect the order in which each control was added to the form Clearly Visual Basic: Programming with Visual Basic 2008

15 Tab Order- View- Tab Order
Clearly Visual Basic: Programming with Visual Basic 2008

16 Do What I Tell You To Do Code Event procedure Code Editor window
Visual Basic instructions Event procedure Tells an object how to respond to an event Code Editor window Used to enter an event procedure’s code Clearly Visual Basic: Programming with Visual Basic 2008

17 The Me.Close() Instruction
Tells the computer to close the current form Method A predefined procedure that you can call (or invoke) when needed Good programming practice: test a procedure after you have coded it Clearly Visual Basic: Programming with Visual Basic 2008

18 Mini Quiz 2 If a text box’s Tab Index is set to 7, it’s indentifying label should be set to: _______ If a text box’s access key is the letter t, you can move the focus to the text box by pressing _____ The first line in a procedure (when you double click on a button) is the: ______ procedure header Clearly Visual Basic: Programming with Visual Basic 2008

19 Review Questions To give the user control, assign the task to a: Button Label Picture Box Text Box Which of the following designates Z as an access key? *Zip Code ^Zip Code &Zip Code #Zip Code The computer processes a button’s click when the user: Clicks the button Uses button access code Tabs to the Button All of the These Which of the following appears in the header and associates the procedure with the btnSave control’s Click Event: The answer is: Handles.btnSave.Click Which of the following tells the computer to stop an application: The answer is Me.Close () Clearly Visual Basic: Programming with Visual Basic 2008

20 Page 93 #3 – Tip Calculator Interface
Note: We are just doing Interfaces, Tab Orders, and Access Keys, NOT the programming- Except the Exit Button

21 Page 94 #4 Property Tax Solution
Clearly Visual Basic: Programming with Visual Basic 2008

22 Property Tax Solution Algorithm
Output: annual property tax Input: Assessed Value Property Tax Rate Algorithm: Enter assessed value and property tax rate Calculate annual property tax by dividing accessed value by 100, and then multiplying the quotient by the property tax rate Display the annual property tax

23 Page 95 #5 Sales Project Clearly Visual Basic: Programming with Visual Basic 2008

24 Sales Solution Algorithm
Output: Total Sales, North Percent, South Percent, East Percent, West Percent Input: North region sales, South sales, East sales, West sales Algorithm: Enter North sales, South Sales, East Sales & West Sales Calculate Total Sales by added up all the regions sales Calculate North’s percent by dividing North’s Sales by Total Sales Calculate South’s percent by dividing South’s Sales by Total Sales Calculate East’s percent by dividing East’s Sales by Total Sales Calculate West’s percent by dividing West’s Sales by Total Sales Display Total Sales, North’s Percent, South’s percent, East’s Percent and West’s Percent

25 Summary A problem’s input, output, and algorithm
Used when designing solution’s interface Text boxes provide area for user to enter data Buttons are used to perform action when clicked Output items typically appear in label controls Object names in Hungarian notation Begin with an ID that identifies the object’s type Clearly Visual Basic: Programming with Visual Basic 2008

26 Summary (continued) To prevent a label from changing its size while application is running: Change its AutoSize property to False A label’s BorderStyle property Determines whether the label has a border An interface’s tab order Determined by number stored in each control’s TabIndex Property The Me.Close() instruction Used to end an application Clearly Visual Basic: Programming with Visual Basic 2008


Download ppt "Clearly Visual Basic: Programming with Visual Basic 2008"

Similar presentations


Ads by Google