Microsoft Visual Basic 2005 BASICS

Slides:



Advertisements
Similar presentations
1.
Advertisements

Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Microsoft Visual Basic: Reloaded Chapter Five More on the Selection Structure.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Visual Basic.NET BASICS Lesson 10 Do Loops. 2 Objectives Explain what a loop is. Use the Do While and Do Until loops. Use the InputBox function. Use the.
Chapter 4: The Selection Structure Programming with Microsoft Visual Basic.NET, Second Edition.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic.NET, Second Edition.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
Chapter 4: Control Structures: Selection
ACSE th Conference The Iconic Programmer Stephen Chen.
The Program Design Phases
CSC103: Introduction to Computer and Programming
Microsoft Visual Basic 2008: Reloaded Fourth Edition
Chapter 4: The Selection Structure
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
Decision Structures and Boolean Logic
Chapter 4: The Selection Structure
Visual C# 2005 Decision Structures. Visual C# Objectives Understand decision making Learn how to make decisions using the if statement Learn how.
Chapter 4: Making Decisions. Understanding Logic-Planning Tools and Decision Making Pseudocode – A tool that helps programmers plan a program’s logic.
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Five More on the Selection Structure.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 4 Decision.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 21, 2005 Lecture Number: 10.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
Chapter 5: More on the Selection Structure
Java Programming Fifth Edition Chapter 5 Making Decisions.
Chapter 5: Making Decisions. Objectives Plan decision-making logic Make decisions with the if and if…else structures Use multiple statements in if and.
Algorithmic state machines
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
Visual Basic CDA College Limassol Campus COM123 Visual Basic Programming Semester C Lecture:Pelekanou Olga Week 4: Understand and implement Decisions.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Variables, operators, canvas, and multimedia Dr. Reyes.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
An Introduction to Programming with C++1 The Selection Structure Tutorial 6.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
Understand Problem Solving Tools to Design Programming Solutions
More on the Selection Structure
Chapter 4: Making Decisions.
Chapter 4: Making Decisions.
Computer Programming I
IF statements.
The Selection Structure
Understand Problem Solving Tools to Design Programming Solutions
Introduction To Flowcharting
Chapter 4: The Selection Structure
Numbering System TODAY AND TOMORROW 11th Edition
Topics The if Statement The if-else Statement Comparing Strings
An Introduction to Visual Basic .NET and Program Design
An Introduction to Programming with C++ Fifth Edition
Making Decisions in a Program
Microsoft Visual Basic 2005 BASICS
Topics The if Statement The if-else Statement Comparing Strings
Lesson 8: Boolean Expressions and "if" Statements
VISUAL BASIC – CHAPTER ONE NOTES An Introduction to Visual Basic
IF if (condition) { Process… }
Computers & Programming Languages
Objectives After studying this chapter, you should be able to:
Design and Implementation
Visual Basic – Decision Statements
Selection Statements.
Microsoft Visual Basic 2005: Reloaded Second Edition
KU College of Engineering Elec 204: Digital Systems Design
Microsoft Visual Basic 2005 BASICS
Chapter 5: The Selection Structure
CHAPTER FOUR VARIABLES AND CONSTANTS
Presentation transcript:

Microsoft Visual Basic 2005 BASICS yo Microsoft Visual Basic 2005 BASICS Lesson 8 If Statements

Objectives Explain how decisions are made in a computer. yo Objectives Explain how decisions are made in a computer. Use the conditional operators. Use If statements to make decisions in programs. Create and read basic flowcharts. Microsoft Visual Basic 2005 BASICS

Objectives (cont.) Use If…Else statements. Use check box controls. yo Objectives (cont.) Use If…Else statements. Use check box controls. Use the logical operators. Microsoft Visual Basic 2005 BASICS

The Building Blocks of Decision Making yo The Building Blocks of Decision Making Programs are limited without the ability to make decisions. Programs must have a means to make decisions. Decision making in computers Generally done in terms of a comparison that returns a True or False response Microsoft Visual Basic 2005 BASICS

The Building Blocks of Decision Making (cont.) Microsoft Visual Basic 2005 BASICS

Using the Conditional Operators yo Using the Conditional Operators The first step to making a decision in a program is to make a comparison. Comparisons are made using the conditional operators. Boolean variables Can be used to store the results of a conditional expression Microsoft Visual Basic 2005 BASICS

Using the Conditional Operators (cont.) Microsoft Visual Basic 2005 BASICS

Using the Conditional Operators (cont.) Microsoft Visual Basic 2005 BASICS

Using If Statements If statement yo Using If Statements If statement Allows you to execute specified code when the result of a conditional expression is True The End If statement marks the end of the If statement. Microsoft Visual Basic 2005 BASICS

Using If Statements (cont.) Code in between the If statement and End If statement is executed if the conditions specified in the If statement are true. Otherwise, the code is skipped. Microsoft Visual Basic 2005 BASICS

Creating and Reading Flowcharts yo Creating and Reading Flowcharts Flowcharts Help you to plan and document program code There are many symbols used in creating flowcharts. The rectangle represents processing data. Use the diamond for making decisions. Use the parallelogram to represent input and output. Microsoft Visual Basic 2005 BASICS

Creating and Reading Flowcharts (cont.) Microsoft Visual Basic 2005 BASICS

Creating and Reading Flowcharts (cont.) Microsoft Visual Basic 2005 BASICS

Using If…Else Statements yo Using If…Else Statements A one-way selection structure Program structure in which the decision is to go “one way” The If…Else statement Allows you to choose between two paths Microsoft Visual Basic 2005 BASICS

Using If…Else Statements (cont.) In an If…Else statement One block of code is executed if the result of an expression is True. Another block is executed if the result is False. Microsoft Visual Basic 2005 BASICS

Using If…Else Statements (cont.) Microsoft Visual Basic 2005 BASICS

Using If…Else Statements (cont.) Microsoft Visual Basic 2005 BASICS

yo Using Check Boxes Check boxes are an important part of the Windows interface. Check boxes allow the programmer to Ask the user a Yes or No question Turn an option on or off Microsoft Visual Basic 2005 BASICS

Using Check Boxes (cont.) Microsoft Visual Basic 2005 BASICS

Checked Property Each check box has a Checked property. yo Checked Property Each check box has a Checked property. Set to True if the box is checked Set to False if the box is not checked A check box has an integrated label. Appears beside it Text property specifies its label Microsoft Visual Basic 2005 BASICS

Checked Property (cont.) Microsoft Visual Basic 2005 BASICS

Setting the Default Checked Property Check boxes can be set to be either checked or unchecked by default. Use the Checked property Microsoft Visual Basic 2005 BASICS

Setting the Checked Property with Code yo Setting the Checked Property with Code The Checked property can be set and/or read from code. Example chkHeart.Checked = True Microsoft Visual Basic 2005 BASICS

Setting the Checked Property with Code (cont.) Microsoft Visual Basic 2005 BASICS

Using the Logical Operators yo Using the Logical Operators Logical operators Can be used to combine several comparisons into one statement Used with True and False values Microsoft Visual Basic 2005 BASICS

Using the Logical Operators (cont.) Microsoft Visual Basic 2005 BASICS

Order of Logical Operators yo Order of Logical Operators Logical operators Processed after the mathematical and conditional operators Logical operators are processed in this order Not And Or Microsoft Visual Basic 2005 BASICS

Order of Logical Operators (cont.) Microsoft Visual Basic 2005 BASICS

yo Summary Decisions are reached by making comparisons. Comparisons in a computer generally return either a True or False value. The conditional operators compare two values and return either True of False, depending on whether the expression is True or False. Microsoft Visual Basic 2005 BASICS

Summary (cont.) A Boolean variable can be used to store the results of an expression that includes conditional operators. The If statement is the most common way to make a decision in a program, and it is a one-way selection structure. The code between the If and the End If is executed if the conditions in the If statement are met. Microsoft Visual Basic 2005 BASICS

Summary (cont.) Flowcharts allow programmers to plan and document program code using symbols connected by lines. An If…Else statement makes a decision between two paths, and it is a two-way selection structure. Microsoft Visual Basic 2005 BASICS

Summary (cont.) Check boxes allow your program to ask the user Yes or No questions or to turn an option on or off. The Checked property of a check box is set to True when the check box is checked and False when the check box is not checked. A check box can be set to be checked or unchecked by default. Microsoft Visual Basic 2005 BASICS

Summary (cont.) Logical operators can be used to combine several comparisons into one statement. They are used with True and False values. The Not operator reverses the value of a Boolean variable or expression. The And operator returns True if the values connected by the And operator are both True. Microsoft Visual Basic 2005 BASICS

Summary (cont.) The Or operator returns True if either value connected by the Or operator is True. The logical operators are last in the order of operations. Of the logical operators, Not comes first, then And, then Or. Microsoft Visual Basic 2005 BASICS