1 / 17

Clearly Visual Basic: Programming with Visual Basic 2008

Clearly Visual Basic: Programming with Visual Basic 2008. Chapter 10 Time to Leave the Nest. Objectives. Nest selection structures Include logical operators in a selection structure’s condition. Nested Selection Structures. Nested selection structure

cshapiro
Télécharger la présentation

Clearly Visual Basic: Programming with Visual Basic 2008

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 10 Time to Leave the Nest

  2. Objectives • Nest selection structures • Include logical operators in a selection structure’s condition Clearly Visual Basic: Programming with Visual Basic 2008

  3. Nested Selection Structures • Nested selection structure • Selection structure contained (nested) within an outer structure • Figure 10-1 • Shows problem specification and its algorithm • Figure 10-2 • Shows modified problem specification along with modified algorithm • Figure 10-3 • Shows correct algorithm Clearly Visual Basic: Programming with Visual Basic 2008

  4. Clearly Visual Basic: Programming with Visual Basic 2008

  5. Clearly Visual Basic: Programming with Visual Basic 2008

  6. Clearly Visual Basic: Programming with Visual Basic 2008

  7. Putting Rob’s Problem Aside • Figure 10-5 • Shows correct algorithm for problem • Consider how you would change the algorithm • Figure 10-6 • Shows modified problem specification and its algorithm Clearly Visual Basic: Programming with Visual Basic 2008

  8. Clearly Visual Basic: Programming with Visual Basic 2008

  9. Clearly Visual Basic: Programming with Visual Basic 2008

  10. Download this interface from Dropbox: AddSub Solution If chkSubtraction.Checked = then If intNum1 > = intNum2 then intAnswer = intNum1-intNum2 Else intAnswer = intNum2-intNum1 End If Else intAnswer = intNum1 + intNum2 End If lblAnswer.Text = intAnswer

  11. That’s Way Too Logical for Me • Logical operators (Boolean operators) • Allow you to combine two or more conditions into one compound condition • Always evaluated after any comparison operators in an expression • Arithmetic operators • Evaluated first in an expression Clearly Visual Basic: Programming with Visual Basic 2008

  12. Clearly Visual Basic: Programming with Visual Basic 2008

  13. Clearly Visual Basic: Programming with Visual Basic 2008

  14. Clearly Visual Basic: Programming with Visual Basic 2008

  15. Clearly Visual Basic: Programming with Visual Basic 2008

  16. Summary • Both paths in a selection structure: • Can include nested selection structures • Nested selection structures • Used when more than one decision must be made before the appropriate action can be taken • When comparing two numbers: • The first number can be greater than, less than, or equal to the second number Clearly Visual Basic: Programming with Visual Basic 2008

  17. Summary (continued) • Logical operators • Can be included in an If…Then…Else statement’s condition • When the AndAlso logical operator is used to combine conditions: • All conditions must be True for the compound condition to be True • AndAlso operator • Has a higher precedence than the OrElse operator • Arithmetic operators • Evaluated first in an expression Clearly Visual Basic: Programming with Visual Basic 2008

More Related