The IfTest and Case Statement1 The IF Test A conditional statement that permits portions of code to be executed only if and when some special condition.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Advertisements

Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Control Structures.
Chapter 4: Control Structures I (Selection)
The if-else Statements
Control Flow Statements: Repetition/Looping
Pemrograman Dasar Control Flow Statements: Decision Making or Selection PTIIK - UB 1.
Computer Programming 12 Mr. Jean April 2 nd, 2014.
Project 6: Working with If Statements Essentials for Design JavaScript Level One Michael Brooks.
Using “So what is the Truth” Template Copy the presentation to your hard drive. Open the slides using slide sorter and copy slides #3, 4, and 5 for each.
Lecture 3: Control Structures - Selection BJ Furman 10SEP2012.
The If Then Else Statement Using JavaScript TIP The If Statement is the fundamental control structure that allows branches in the flow of control in a.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Decision Making with Control Structures and Statements (non-audio version) © Dr. David.
The "if structure" is used to execute statement(s) only if the given condition is satisfied.
CS1022 Computer Programming & Principles
Short circuit code for boolean expressions: Boolean expressions are typically used in the flow of control statements, such as if, while and for statements,
MIS 3200 – Unit 4 Complex Conditional Statements – else if – switch.
CS-1010 Dr. Mark L. Hornick 1 Selection Statements and conditional expressions.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
INTRODUCTION TO PYTHON PART 3 - LOOPS AND CONDITIONAL LOGIC CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
COMP 1001: Introduction to Computers for Arts and Social Sciences Programming in Scratch Monday, May 16, 2011.
Using Control Structures. Goals Understand the three basic forms of control structures Understand how to create and manage conditionals Understand how.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
InvEasy (Project1) Please use speaker notes for additional information!
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Copyright 2003 Scott/Jones Publishing Making Decisions.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
Computer-made Decisions Chapter 3 & 4. Overview u Variable Scope u Conditionals  Relational Operators  AND, OR, NOT u If Statements u MsgBox function.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Loops Robin Burke IT 130. Outline Announcement: Homework #6 Conditionals (review) Iteration while loop while with counter for loops.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
General Computer Science for Engineers CISC 106 Lecture 2^4 Roger Craig Computer and Information Sciences 03/23/2009.
Pay Example (PFirst98) Please use speaker notes for additional information!
While and If-Else Loops ROBOTC Software. While Loops While loop is a structure within ROBOTC Allows a section of code to be repeated as long as a certain.
ITK 168 Decisions Dr. Doug Twitchell September 20, 2005.
31/01/ Selection If selection construct.
Language Find the latest version of this document at
Lesson thirteen Conditional Statement "if- else" ©
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Conditional statements and boolean expressions Arithmetic, relational and logical operators.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
IF STATEMENTS AND BOOLEAN EXPRESSIONS. BOOLEAN EXPRESSIONS Evaluate to a value of true or false Use relational or equivalence operators Boolean operators.
PYTHON IF-STATEMENTS. What you know If something is true, then something happens Example If you heat water to 100 degrees Celsius, then it boils If it.
Special Triangles Review
A variable is a name for a value stored in memory.
Chapter 4: Making Decisions.
C-Language Lecture By B.S.S.Tejesh, S.Neeraja
Chapter 4: Making Decisions.
Delete text and place photo here.
Chapter 5 Structures.
MIS 3200 – Unit 4 Complex Conditional Statements else if switch.
The C++ IF Statement Part 2 Copyright © Curt Hill
While Loops and If-Else Structures
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
Selection CSCE 121 J. Michael Moore.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Lec 4: while loop and do-while loop
Do … Loop Until (condition is true)
if-else Structures Principles of Engineering
If statements (Inven1, Inven2, Inven2a, Inven3, Inven3a)
Chapter 3: Selection Structures: Making Decisions
Chapter 3: Selection Structures: Making Decisions
Selections and Loops By Sarah, Melody, Teresa.
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
CHAPTER FOUR VARIABLES AND CONSTANTS
The boolean type and boolean operators
Presentation transcript:

The IfTest and Case Statement1 The IF Test A conditional statement that permits portions of code to be executed only if and when some special condition applies. (If there is some beer, get me a bottle, otherwise get me a cola.) (If it is raining, bring an umbrella)

The IfTest and Case Statement2 IF Test If (Condition T/F) Then ’ (do true stuff) Else ’ (do false stuff) End If

The IfTest and Case Statement3 IF Test (short form) If (Condition T/F) Then ’ (do true stuff) End If (use only if there is nothing to do in the Else branch)

The IfTest and Case Statement4 IF Test Example (1) Private Sub cmdDo_Click() If cmdDo.Caption = "Talk" Then lblBox.Caption = "ding ding" cmdDo.Caption = "clear" Else lblBox.Caption = "" cmdDo.Caption = "Talk" End If End Sub

The IfTest and Case Statement5 IF Test Example (2) >

The IfTest and Case Statement6 IF Test Example (3) Private Sub cmdBlink_Click() If lblBox.Visible = True then lblBox.Visible = False Else lblBox.Visible = True End If End Sub Since lblBox.Visible is boolean why not use If lblBox.Visible then

The IfTest and Case Statement7 The CASE Statement (1) This statement can be used instead of repeated “IF” tests. It is clearer and nearly self documenting. The following example is probably the best way to illustrate it. It allows a multi-way choice between routing something to the northwest, the midwest or to some unknown area. Many more branches are possible.

The IfTest and Case Statement8 The CASE Statement (2) Private Sub cmdWhere_Click() Select Case txtState.Text Case "WA", "OR" lblOffTo.Caption = "Northwest" Case "IL", "WI", "MN", "IA" lblOffTo.Caption = "Midwest" Case Else lblOffTo.Caption = ”unknown" End Select End Sub

The IfTest and Case Statement9 The CASE Statement (3)