Your SlideShare is downloading. ×
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Ppt lesson 08
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ppt lesson 08

882

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
882
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Microsoft Visual Basic 2005 BASICS Lesson 8 If Statements
  • 2. 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.
  • 3. Objectives (cont.)
    • Use If…Else statements.
    • Use check box controls.
    • Use the logical operators.
  • 4. 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
  • 5. The Building Blocks of Decision Making (cont.)
  • 6. 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
  • 7. Using the Conditional Operators (cont.)
  • 8. Using the Conditional Operators (cont.)
  • 9. 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.
  • 10. 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.
  • 11. 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.
  • 12. Creating and Reading Flowcharts (cont.)
  • 13. Creating and Reading Flowcharts (cont.)
  • 14. 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
  • 15. 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.
  • 16. Using If…Else Statements (cont.)
  • 17. Using If…Else Statements (cont.)
  • 18. 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
  • 19. Using Check Boxes (cont.)
  • 20. 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
  • 21. Checked Property (cont.)
  • 22. Setting the Default Checked Property
    • Check boxes can be set to be either checked or unchecked by default.
      • Use the Checked property
  • 23. Setting the Checked Property with Code
    • The Checked property can be set and/or read from code.
    • Example
      • chkHeart.Checked = True
  • 24. Setting the Checked Property with Code (cont.)
  • 25. Using the Logical Operators
    • Logical operators
      • Can be used to combine several comparisons into one statement
      • Used with True and False values
  • 26. Using the Logical Operators (cont.)
  • 27. Order of Logical Operators
    • Logical operators
      • Processed after the mathematical and conditional operators
    • Logical operators are processed in this order
      • Not
      • And
      • Or
  • 28. Order of Logical Operators (cont.)
  • 29. 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.
  • 30. 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.
  • 31. 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.
  • 32. 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.
  • 33. 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.
  • 34. 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.

×