Chapter 3 Part 21 Displaying Output Chapter 3 Section 3.5Output Formatting Chapter 3 Section...
-
Upload
gregory-booker -
Category
Documents
-
view
239 -
download
4
Transcript of Chapter 3 Part 21 Displaying Output Chapter 3 Section 3.5Output Formatting Chapter 3 Section...
Chapter 3 Part 2 1
Displaying Output
Chapter 3 Section 3.5 Output FormattingChapter 3 Section 3.6 Group Boxes, etc.Chapter 3 Section 3.7 Sample ProgramChapter 3 Section 3.8 Logic Errors
Chapter 3 Part 2 2
Number Formats
Function Description
FormatNumber Includes commas and specified number of decimal points.
FormatCurrency Includes commas, decimal points, and currency symbol.
FormatPercent Formats value as a percent.
FormatDateTime Formats expression as a date, time, or both.
Chapter 3 Part 2 3
FormatNumber Function
Default Format 2 decimal places Commas as needed
Syntax FormatNumber(value)
ExamplesFormatNumber(12345.678) 12,345.68*FormatNumber(12) 12.00FormatNumber(.75) 0.75
Note: Rounding occurs.
Chapter 3 Part 2 4
FormatNumber Function*
Optional ArgumentFormatNumber(value, #decimal places)
Examples:FormatNumber(4567, 4) 4,567.0000
FormatNumber(45678.473, 1) 45,678.5
FormatNumber(4567.243, 0) 4,567 Skip: bottom section of p. 139
& top p. 140Next several slides show values as arguments as examples;use variable names in real programs to avoid magic numbers.
Chapter 3 Part 2 5
FormatCurrency Function
Default Format: Dollar sign Rounds to 2 decimal places.
Examples:FormatCurrency(87321.784) $87,321.78
FormatCurrency(44) $44.00
FormatCurrency(3.658) $3.66
Chapter 3 Part 2 6
FormatPercent Function
Default Format: Multiplies argument by 100 Rounds to 2 decimal places Displays percent sign
Examples:FormatPercent(.783) 78.30%FormatPercent(.48129) 48.13%FormatPercent(55) 5,500.00%FormatPercent(.3862, 1) 38.6%
Chapter 3 Part 2 7
FormatDateTime
SyntaxFormatDateTime(expression [, Format])
Examples:FormatDateTime(systemDate, DateFormat.LongDate)
Wednesday, September 17, 2003
FormatDateTime(systemDate, DateFormat.ShortDate)
9/17/03
Chapter 3 Part 2 8
FormatDateTime
More ExamplesFormatDateTime(systemDate, DateFormat.LongTime)
03:22:18 PM
FormatDateTime(systemDate, DateFormat.ShortDate)
15:22
FormatDateTime(systemDate, DateFormat.GeneralDate)
09/17/2003 3:22:18 PM
Chapter 3 Part 2 9
Label Formats
PropertiesSet TextAlign for values (typically right).
CodelblTotal.Text = FormatCurrency(Total)
Chapter 3 Part 2 10
Formatted Text and Captions
Chapter 3 Part 2 11
GroupBox Control (p. 144)
Appears as a rectangular border with an optional title in the upper-left corner.
Contains and organizes controls.
Chapter 3 Part 2 12
GroupBox Creation Process
1. Create GroupBox control first.
2. Select the GroupBox.
3. Double-click controls from toolbox to appear within the GroupBox.
Other controls are part of GroupBox and move with it.
Chapter 3 Part 2 13
GroupBox ControlMoving Existing Controls to It
1. Select existing control(s).
2. Cut the selected control(s).
3. Select the GroupBox control.
4. Paste the selected control(s).
Chapter 3 Part 2 14
GroupBox TabIndex
Set GroupBox control with Tab Order. Click controls inside GroupBox to provide tab
order for those controls.
Chapter 3 Part 2 15
GroupBox Access Keys
GroupBox itself cannot have focus. You can use & to set an access key. When a person uses the access key, the
focus moves to the control with the lowest TabIndex value inside the GroupBox control.
Chapter 3 Part 2 16
Form Formatting (pp. 146-147)
Selecting and Moving Multiple Controls Click and drag a selection box around the
controls. Press Ctrl as you click controls.
Chapter 3 Part 2 17
Format Menu (Review)
Align (p. 148) Lefts Rights Centers Horizontal Alignment
Size (p. 149) Make Same Size
Chapter 3 Part 2 18
Form Load
Executes when the form loads into memory. Example: declaring object variable to create
instance of splash screen form (see Chapters 7 and 8)
Double-click form to see Form Load event procedure.
Chapter 3 Part 2 19
Section 3.7 Program Development
Complete Section 3.7 to develop the Highlander Hotel program. Note design sketches (pp. 150-151). Study control planning grids, including
Methods (pp. 151-153). Follow flowcharts (pp. 154-155).
Hint: Study flowchart shapes in case you see a test question.
Complete Tutorial 3-10 (pp. 156-161).
Chapter 3 Part 2 20
Color Changes in Code (p. 159)
ForeColor and BackColor Properties Color.Black
Color.RedColor.Blue
lblOutput.ForeColor = Color.Blue
Chapter 3 Part 2 21
Logic Errors (p. 162)
Mistake that does not prevent a program from running BUT causes the program to produce inaccurate results.
Examples: Mathematical errors Copying value to the wrong variable Incorrect assignment of constant values.
Chapter 3 Part 2 22
Debugging Logic Errors
Read through Section 3.8. Complete Tutorial 3-12 (pp. 162-167).
Set a breakpoint—line selected in code.
Chapter 3 Part 2 23
Checkpoints for Individual Review
page 144 pages 149 and 150 page 168
Answers at end of book
Chapter 3 Part 2 24
Additional Review
Summary Review Questions
Fill-in-the-blank True or False Multiple Choice Short Answer What Do You Think? Find the Error Algorithm Workbench
Answers on ftp site.