IT 236 User Interface Development: Tonight
IT 236 User Interface Development: Tonight
___________________________________
___________________________________
___________________________________
___________________________________
Slide 2 ___________________________________
Tonight:
___________________________________
Branching
Conditions
If-Else statement ___________________________________
Input validation
Check boxes and radio buttons (again…)
Lab Session 2 (Room 819, 7:30pm-9:00pm) ___________________________________
___________________________________
___________________________________
___________________________________
Slide 3 ___________________________________
Branching
___________________________________
So far, all of our event procedures have
consisted of straight-line code
The same sequence of statements is executed
each time it is run
___________________________________
Today, we will modify the flow of control in
our procedures by adding branching
Choose among one or more sets of statements, ___________________________________
based on the result of some test (or condition)
___________________________________
___________________________________
___________________________________
Slide 4 ___________________________________
Logical Operators
___________________________________
Take two values as operands, do comparison,
and return a boolean (i.e., true/false) value
=
<>
is equal to
is not equal to
___________________________________
< is less than
<= is less than or equal to
> is greater than ___________________________________
>= is greater than or equal to
___________________________________
___________________________________
___________________________________
Slide 5 ___________________________________
Dictionary (Lexicographic) Order
___________________________________
Compare the Strings one position at a time until you
find a character where they differ
Compare the characters in that position – the String with
the character that occurs earlier comes earlier in the order
If they never differ and you run out of characters:
___________________________________
If one String runs out first, the shorter String comes earlier
in the order
If both Strings run out at the same time with no
___________________________________
differences, they are in fact the same String!
___________________________________
___________________________________
___________________________________
Slide 6 ___________________________________
Logical Operators
___________________________________
Take two boolean values as operands,
combine them, and return a boolean value
cond1 And cond2
true if and only if both cond1 and cond2 are true ___________________________________
cond1 Or cond2
true if and only if at least one of cond1 and cond2 is true
cond1 Xor cond2
___________________________________
___________________________________
___________________________________
___________________________________
Slide 7 ___________________________________
If Statement
___________________________________
Choose which of two actions to perform, depending
on the result of some test
Syntax: If test Then
action1 ___________________________________
Else
action2
End If
___________________________________
___________________________________
___________________________________
Slide 8 ___________________________________
Repeated If-Elses
___________________________________
Can choose among more than two actions using a
sequence of several tests:
If test1 Then
___________________________________
action1
ElseIf test2 Then
action2
ElseIf test3 Then
action3
Else
action4
End If
___________________________________
___________________________________
___________________________________
Slide 9 ___________________________________
Input Validation
___________________________________
Can use branching to make sure that user
input satisfies some requirements before
proceeding, e.g.:
certain required fields are filled in
___________________________________
numerical values are in some range
lengths of input Strings are correct
___________________________________
___________________________________
___________________________________
___________________________________
Slide 10 ___________________________________
Testing the Checked Property
___________________________________
Can branch based on whether or not check
boxes and radio buttons are checked:
If nameOfControl.Checked Then
action1 ___________________________________
Else
action2
EndIf
___________________________________
___________________________________
___________________________________
Slide 11 ___________________________________
Shared Event Procedures
___________________________________
One event procedure can be set to respond to
several different events
Put list of events after the Handles keyword
in the procedure header
___________________________________
... Handles contro11.Event1, control2.Event2, _
___________________________________
control3.Event3
___________________________________
___________________________________
___________________________________
Slide 12 ___________________________________
Summarizing Example
___________________________________
Take burger orders at Wendy’s
single, double, or triple burger (1.99, 2.99, 3.99)
other options: cheese (.50), ketchup, mustard
___________________________________
___________________________________
___________________________________
___________________________________
Slide 13 ___________________________________
Lab Exercise 2
___________________________________
Text boxes to enter employee name and type
Types: S(alaried), H(ourly), U(npaid)
Button to compute monthly pay
S: prompt for monthly salary with input box
___________________________________
H: prompt for hourly rate and hours worked with
two input boxes and compute monthly pay
U: monthly pay is always zero
Display name, type, and monthly pay on one
___________________________________
line of a list box
___________________________________
___________________________________
___________________________________
Slide 14 ___________________________________
Next Time:
___________________________________
More branching
Looping?
Programming examples ___________________________________
Review for Midterm Exam
(Please suggest particular topics…)
___________________________________
___________________________________
___________________________________