Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
32 views

IT 236 User Interface Development: Tonight

This document contains slides from a lecture on user interface development. It discusses branching, conditions, and the if-else statement. Topics covered include logical operators, dictionary order, input validation using if statements, and repeated if-else statements to choose among multiple actions. The slides provide examples and syntax for using if statements and elseif statements to execute different code blocks depending on conditional test results.

Uploaded by

crutili
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

IT 236 User Interface Development: Tonight

This document contains slides from a lecture on user interface development. It discusses branching, conditions, and the if-else statement. Topics covered include logical operators, dictionary order, input validation using if statements, and repeated if-else statements to choose among multiple actions. The slides provide examples and syntax for using if statements and elseif statements to execute different code blocks depending on conditional test results.

Uploaded by

crutili
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Slide 1 ___________________________________

IT 236 User Interface Development


Lecture 4 ___________________________________
Eric J. Schwabe
School of CTI, DePaul University ___________________________________
Spring 2008

___________________________________

___________________________________

___________________________________

___________________________________

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
___________________________________

true if and only if exactly one of cond1 and cond2 is true


 Not cond1
true if and only if cond1 is false

___________________________________

___________________________________

___________________________________
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

 When the statement is reached:


1. Evaluate test
___________________________________
2. If result is true, execute action1; if false, execute action2

___________________________________

___________________________________

___________________________________

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

 Only the action corresponding to the first satisfied


condition will be executed
___________________________________

___________________________________

___________________________________

___________________________________

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

 The Checked property has a true/false value,


so it can be used by itself as a condition…
___________________________________

___________________________________

___________________________________

___________________________________

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
___________________________________

 Keep track of current choices in labels


 Button to compute price and report order and
price in list box
 Button to clear current choices ___________________________________
 …How would we go about doing this?

___________________________________

___________________________________

___________________________________
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…)

(Assignment 4 has been posted, due next week…)


___________________________________

___________________________________

___________________________________

___________________________________

You might also like