Professional Documents
Culture Documents
Reloaded
Fourth Edition
Chapter Four
Making Decisions in a Program
Objectives
• Concatenate strings
• Use the ControlChars.NewLine constant
• Change the case of a string
• Include a check box in an interface
• Generate random numbers
• Comparison operators:
– Have no order of precedence
– Are evaluated from left to right in an expression
– Are evaluated after any arithmetic operators in the
expression
• All expressions containing comparison operators
evaluate to True or False only
Figure 4-15: Code entered in the Display button’s Click event procedure
Figure 4-15: Code entered in the Display button’s Click event procedure (cont’d.)
Figure 4-18: Sample run of the Addition and Subtraction Calculator application
Figure 4-22: How to use the ToUpper and ToLower methods (cont'd.)
Microsoft Visual Basic 2010: Reloaded, Fourth Edition 37
The ToUpper and ToLower Methods
(cont’d.)
Figure 4-24: A different interface for the Addition and Subtraction Calculator
application
Microsoft Visual Basic 2010: Reloaded, Fourth Edition 41
Comparing Boolean Values (cont’d.)
Figure 4-27: Truth tables for the AndAlso and OrElse logical operators
• Data validation:
– Process of verifying that the input data is within the
expected range
Figure 4-28: Two ways of writing the calcButton Click event procedure
Microsoft Visual Basic 2010: Reloaded, Fourth Edition 51
Figure 4-28: Two ways of writing the calcButton Click event procedure (cont’d.)
Microsoft Visual Basic 2010: Reloaded, Fourth Edition 52
The Carroll Company Application
(cont'd.)
Figure 4-29: Sample run of the Carroll Company application using valid data
Figure 4-30: Sample run of the Carroll Company application using invalid data
Microsoft Visual Basic 2010: Reloaded, Fourth Edition 53
Summary of Operators
Figure 4-36: MainForm for the Find the Mouse Game application
Product 1
Product 2
Product 3
Product 4
Tax
Total