Introduction to Computing Dr. Nadeem A Khan. Lecture 21.

Slides:



Advertisements
Similar presentations
Unit 9 It's warm 清丰县第一实验小学 唐利娟.
Advertisements

What’s your favorite season?
IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
Introduction to Computing Dr. Nadeem A Khan. Lecture 23.
Introduction to Computing Dr. Nadeem A Khan. Lecture 22.
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
Introduction to Computing Dr. Nadeem A Khan. Lecture 27.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Introduction to Computing Dr. Nadeem A Khan. Lecture 17.
CP1020 Week 5 Selection Continued. CP1020 University of Wolverhampton - Steve Garner and Ian Coulson if then else zWe can use if then else statements.
Chapter 5 - VB.Net by Schneider
Introduction to Computing Dr. Nadeem A Khan. Lecture 19.
Introduction to Computing Dr. Nadeem A Khan. Lecture 11.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
Introduction to Computing Dr. Nadeem A Khan. Lecture 14.
Introduction to Computing Dr. Nadeem A Khan. Lecture 6.
Introduction to Computing Dr. Nadeem A Khan. Lecture 28.
Introduction to Computing Dr. Nadeem A Khan. Lecture 13.
Chapter 5 - Visual Basic Schneider1 Chapter 5 Decisions.
Introduction to Computing Dr. Nadeem A Khan. Lecture 18.
7Lc A plan for all seasons 2 Explain what a hemisphere is.
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
Introduction to Computing Dr. Nadeem A Khan. Lecture 5.
Chapter 51 Select Case block A decision-making structure that simplifies choosing among several actions. Avoids complex nested If constructs. If blocks.
For…Next : Nested Loop X= 0 For i = 0 To 4 For j = 0 To i-1 X=X+(i+j-1) Next j Next i How many times the inner loop is executed? What is x at the end of.
T ODAY ’ S Q UOTE "The computers do what you tell them to do, not what you want them to do. " ( Alexander Atanasov)
Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks.
Chapter 4 - VB 2008 by Schneider1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks.
Chapter 5 - VB 2005 by Schneider1 Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks 5.4 A Case Study: Weekly.
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
Changes Occur in: Winter, Spring, Summer, Autumn
MIS 216 Exam1 Review Spring What to expect Questions like those on the home works and on the quizzes Evaluate code Create code Multiple choice and.
High Frequency Words favourite My favourite season is spring. HFW – P.2 – Unit Find this on page 54 of your MP book.
Unit2 My favourite season. spring summer fall winter.
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
Loop and repetition. Today Passing values to and back from Sub procedures Option Buttons Do While Loops For Loops Population Growth.
1 VB-04-Control Structures 16 March 2016 Visual Basic Control Structures - Selection.
Chapter 4 - VB 2008 by Schneider1 Chapter 4 – Decisions 4.1 Relational and Logical Operators 4.2 If Blocks 4.3 Select Case Blocks.
1 Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks 5.4 A Case Study: Weekly Payroll.
Week 4 Relational and Logical Operators Dr. Jennifer Cunningham.
Select Case Blocks School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 8, Monday 3/03/2003)
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Introduction to Computing Dr. Nadeem A Khan. Lecture 21.
A season is a time of the year.
Introduction to Computing
Chapter 4 - VB 2008 by Schneider
Spring Summer Autumn Winter
Introduction to Computing
What are the Common Seasonal Car Repairs?.
SEASONS.
Chapter 1: Introduction
Chapter 5 - Visual Basic Schneider
Power Point by Jill Davis Song by Jack Hartmann, Rhymin’ to the Beat
Bellwork Solve by graphing y < x + 2 y > -1/2x + 5.
Season & Weather Unit 5 The four seasons.
Morning Warm- Up. What changes can we observe in nature
Presentation transcript:

Introduction to Computing Dr. Nadeem A Khan

Lecture 21

IF BLOCK EXTENDED IF condition 1 Then action1 ElseIf condition 2 Then action 2 action 2 ElseIf condition 3 Then action 3 Else action 4 End If

Select Case Blocks

► Example: Sub Command1_Click ( ) Picture1.Cls Let num = Val(Text1.Text) Select Case num Case 1 Picture1.Print “Buckle my shoe.” Case 2 Picture1.Print “Pick the sticks.” Case 3,4,5,6 Picture1.Print “Lay them straight.” Case Else Picture1.Print “Start all over again.” End Select End Sub

Select Case Block ► General form Select Case selector Case valueList1 action1 Case valueList2 action2.. Case Else action of last resort End Select

Select Case Block (Contd.) ► See fig. 5.4:Flow Chart for Select Case block block

Another example

Sub Command1_Click ( ) Sub Command1_Click ( ) Dim x As Integer, y As Integer, num As Integer Let x=2 Let y=3 Let num = Val(Text1.Text) Select Case num Case y-x, x Picture1.Print “Buckle my shoe.” Case Is<=4 Picture1.Print “Pick up sticks.” Case x+y To x*y Picture1.Print “Lay them straight.” Case Else Picture1.Print “Start all over again.” End Select End Sub

Still another example

Sub Command1_Click ( ) Dim season As string Rem Determine the number of days in a season Picture1.Cls Let season = Text1.Text Picture1.Print season; “has”; NumDays(season);“days.” End Sub Select Case Block (Contd.)

Function NumDays (seasons As String) As Integer Select Case UCase$(season) Case “WINTER” NumDays = 87 Case “SPRING” NumDays = 92 Case “SUMMER”, “AUTUMN”, “FALL” NumDays = 93 End Select End Functions Select Case Block (Contd.)

► Study chapter 5 with all its comments and examples. Solve some problems as well! Note: