SlideShare ist ein Scribd-Unternehmen logo
1 von 57
CHAPTER FIVE Decision Structures
Chapter 5: Decision Structures 2 Objectives Use the GroupBox object Place RadioButton objects in applications Display a message box Make decisions using If
Then statements Make decisions using If
Then
Else statements Make decisions using nested If statements
Chapter 5: Decision Structures 3 Objectives Make decisions using logical operators Make decisions using Case statements Insert code snippets Test input to ensure a value is numeric
Chapter 5: Decision Structures 4 Preview the Chapter Project
Chapter 5: Decision Structures 5 Using the GroupBox Object Drag the GroupBox object in the Containers category of the Toolbox over the Form object to the approximate location where you want to place the GroupBox object When the mouse pointer is in the correct location, release the left mouse button. With the GroupBoxobject selected, scroll in the Properties window to the (Name) property. Double-click in the right column of the (Name) property and then enter the name grpWoodType Click to the right of the Size property of the GroupBox object and enter 125,100 as the size. Change the Font property to Goudy Old Style, Regular, Size 12. Change the BackColor property to White
Chapter 5: Decision Structures 6 Using the GroupBox Object
Using the GroupBox Object Chapter 5: Decision Structures 7
Chapter 5: Decision Structures 8 Adding the RadioButton Objects Drag and drop one RadioButton object from the Toolbox into the GroupBox object on the Form object.Drag a second RadioButton object from the Toolbox into the GroupBox object, using blue snap lines to align and separate the RadioButton objects vertically Release the left mouse button to place the RadioButton object on the Form object within the GroupBox object. Using the same technique, add a third RadioButton object
Chapter 5: Decision Structures 9 Adding the RadioButton Objects Name the RadioButton objects by selecting a RadioButton object, double-clicking in the right column of the (Name) property in the Properties window, and entering the name. The names for the radio buttons, from top to bottom, should be radPine, radOak, and radCherry Change the Text property for each RadioButton by double-clicking in the right column of the Text property and typing Pine for the first RadioButton, Oak for the second RadioButton and Cherry for the third RadioButton
Chapter 5: Decision Structures 10 Adding the RadioButton Objects
Adding the RadioButton Objects Chapter 5: Decision Structures 11
Chapter 5: Decision Structures 12 Windows Application Container Objects
Chapter 5: Decision Structures 13 Displaying a Message Box
Chapter 5: Decision Structures 14 Displaying a Message Box
Chapter 5: Decision Structures 15 Displaying a Message Box
Chapter 5: Decision Structures 16 Displaying a Message Box
Displaying a Message Box Chapter 5: Decision Structures 17
Chapter 5: Decision Structures 18 Message Box IntelliSense In the code editing window, inside the event handler you are coding, type msgto display MsgBox in the IntelliSense list Press the Tab key to select MsgBox from the IntelliSense list. Type the following text: (“You have been disconnected from the Internet”, m) Select the MsgBoxStyle.AbortRetryIgnore argument by pressing the UP ARROW until the correct argument is highlighted.Type a comma.Then type "ISP” and a right parenthesis  Click the Start Debugging button on the Standard toolbar
Message Box IntelliSense Chapter 5: Decision Structures 19
Chapter 5: Decision Structures 20 Displaying a Message Box
Chapter 5: Decision Structures 21 Making Decisions with Conditional Statements: Using an If
Then Statement A decision structure is one of the three fundamental control structures used in computer programming When a condition is tested in a Visual Basic program, the condition either is true or false
Chapter 5: Decision Structures 22 Relational Operators
Chapter 5: Decision Structures 23 Relational Operators With the insertion point located in the correct location in the code, type ifand then press the SPACEBAR Type inta to select the variable named intAge in the IntelliSense list. Then, type >=18as the condition to be tested. Press the ENTER key On the blank line, enter the statement that should be executed when the condition is true. To place the message, “You are old enough to vote” in the Text property of the lblVotingEligibility Label object, insert the code shown in Figure 5-33 on page 315. Remember to use IntelliSense to reference the lblVotingEligibility Label object
Relational Operators Chapter 5: Decision Structures 24
Chapter 5: Decision Structures 25 Comparing Strings A string value comparison compares each character in two strings, starting with the first character in each string
Chapter 5: Decision Structures 26 Comparing Different Data Types Every type of data available in Visual Basic can be compared Different numeric types can be compared to each other A single string character can be compared to a Char data type
Using the If
Then
Else Statement Chapter 5: Decision Structures 27
Chapter 5: Decision Structures 28 Using the If
Then
ElseIf Statement
Nested If Statements Chapter 5: Decision Structures 29
Nested If Statements Chapter 5: Decision Structures 30
Chapter 5: Decision Structures 31 Matching If, Else, and End If Entries If statements must be fully contained within the outer If statement Place the correct statements with the correct If and Else statements within the nested If statement This illustration shows incorrect logic
Testing the Status of a RadioButton Object in Code Chapter 5: Decision Structures 32
Chapter 5: Decision Structures 33 Block-Level Scope Scope is defined by where the variable is declared within a program Within an event handler, an If
Then
Else statement is considered a block of code Variables can be declared within a block of code The variable can be referenced only within the block of code where it is declared
Chapter 5: Decision Structures 34 Using Logical Operators When more than one condition is included in an If...Then...Else statement, the conditions are called a compound condition
Using the And Logical Operator Chapter 5: Decision Structures 35
Using the Or Logical Operator Chapter 5: Decision Structures 36
Using the Not Logical Operator Chapter 5: Decision Structures 37
Chapter 5: Decision Structures 38 Other Logical Operators
Chapter 5: Decision Structures 39 Order of Operations for Logical Operators
Chapter 5: Decision Structures 40 Select Case Statement In some programming applications, different operations can occur based upon the value in a single field
Select Case Statement Chapter 5: Decision Structures 41
Chapter 5: Decision Structures 42 Select Case Test Expressions
Chapter 5: Decision Structures 43 Using Relational Operators in a Select Case Statement
Using Ranges in Select Case Statements Chapter 5: Decision Structures 44
Chapter 5: Decision Structures 45 Selecting Which Decision Structure to Use You might be faced with determining if you should use the Select Case statement or the If...Then...ElseIf statement to solve a problem Generally, the Select Case statement is most useful when more than two or three values must be tested for a given variable The If...Then...ElseIf statement is more flexible More than one variable can be used in the comparison Compound conditions with the And, Or, and Not logical operators can be used
Chapter 5: Decision Structures 46 Code Snippets Right-click the line in the code editing window where you want to insert the snippet Click Insert Snippet on the shortcut menu Double-click the folder Code Patterns - If, For Each,Try Catch, Property, etc, which contains commonly used code such as the If . . . Then . . . Else statement  Double-click the Conditionals and Loops folder because an If...Then...Else statement is a conditional statement Double-click the If...Else...End If Statement code snippet
Chapter 5: Decision Structures 47 Code Snippets
Code Snippets Chapter 5: Decision Structures 48
Chapter 5: Decision Structures 49 Validating Data Developers should anticipate that users will enter invalid data Developers must write code that will prevent the invalid data from being used in the program to produce invalid output
Chapter 5: Decision Structures 50 Testing Input to Determine If the Value Is Numeric The Visual Basic IsNumeric function can check the input value to determine if the value can be converted into a numeric value such as an Integer or Decimal data type
Chapter 5: Decision Structures 51 Checking for a Positive Number
Program Design Chapter 5: Decision Structures 52
Program Design Chapter 5: Decision Structures 53
Program Design Chapter 5: Decision Structures 54
Chapter 5: Decision Structures 55 Chapter Summary Use the GroupBox object Place RadioButton objects in applications Display a message box Make decisions using If
Then statements Make decisions using If
Then
Else statements Make decisions using nested If statements
Chapter 5: Decision Structures 56 Chapter Summary Make decisions using logical operators Make decisions using Case statements Insert code snippets Test input to ensure a value is numeric
CHAPTER FIVE COMPLETE Decision Structures

Weitere Àhnliche Inhalte

Was ist angesagt?

Notes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsNotes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsWilliam Olivier
 
Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08Linda Bodrie
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingAbha Damani
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07Linda Bodrie
 
Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6comp274
 
3 in out
3 in out3 in out
3 in outfyjordan9
 
Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6helpido9
 
Which is not a step in the problem
Which is not a step in the problemWhich is not a step in the problem
Which is not a step in the problemkasguest
 

Was ist angesagt? (12)

Notes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculationsNotes how to work with variables, constants and do calculations
Notes how to work with variables, constants and do calculations
 
Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
 
Decisions
DecisionsDecisions
Decisions
 
Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6Cis 355 ilab 4 of 6
Cis 355 ilab 4 of 6
 
3 in out
3 in out3 in out
3 in out
 
Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6Cis 355 i lab 4 of 6
Cis 355 i lab 4 of 6
 
Decisions
DecisionsDecisions
Decisions
 
Cis160 Final Review
Cis160 Final ReviewCis160 Final Review
Cis160 Final Review
 
Which is not a step in the problem
Which is not a step in the problemWhich is not a step in the problem
Which is not a step in the problem
 
Visual Logic Project - 1
Visual Logic Project - 1Visual Logic Project - 1
Visual Logic Project - 1
 

Andere mochten auch

Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±
Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±
Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±Kazuhide Maruyama
 
X.9 yuliana.ppt
X.9 yuliana.pptX.9 yuliana.ppt
X.9 yuliana.pptYulianalim97
 
Kisah benar tragedi memali
Kisah benar tragedi memaliKisah benar tragedi memali
Kisah benar tragedi memalihasan0812
 
PrÀsentation abwasser cem 40 a de
PrÀsentation abwasser cem 40 a dePrÀsentation abwasser cem 40 a de
PrÀsentation abwasser cem 40 a deJulija_RU
 
Premiere Reunion Publique
Premiere Reunion PubliquePremiere Reunion Publique
Premiere Reunion Publiqueguest275f13
 
Roots, Stems, and Leaves Power Point
Roots, Stems, and Leaves Power PointRoots, Stems, and Leaves Power Point
Roots, Stems, and Leaves Power PointMr. Kyle Collins
 
Test communications
Test communicationsTest communications
Test communicationsdeborathompson
 
Spill Group 212 Event Final
Spill Group   212 Event FinalSpill Group   212 Event Final
Spill Group 212 Event FinalNEWPEOPLE
 
Legionnaires Disease
Legionnaires DiseaseLegionnaires Disease
Legionnaires Diseaseindus329
 
Compromiso Familia y Escuela TIC 2.0
Compromiso Familia y Escuela TIC 2.0Compromiso Familia y Escuela TIC 2.0
Compromiso Familia y Escuela TIC 2.0Fapace AlmerĂ­a
 
National library case study
National library case studyNational library case study
National library case studyJoeyDorrington
 
Dma Competencies 2011 12
Dma Competencies 2011 12Dma Competencies 2011 12
Dma Competencies 2011 12danikaolson
 
Lambros Papayiannis presentation: whitefly viruses (in Greek)
Lambros Papayiannis presentation: whitefly viruses (in Greek)Lambros Papayiannis presentation: whitefly viruses (in Greek)
Lambros Papayiannis presentation: whitefly viruses (in Greek)Agriculural Research Institute
 
Ge fruehstuecken fit
Ge fruehstuecken fitGe fruehstuecken fit
Ge fruehstuecken fitCoachherbalife
 
σΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎα
σΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎασΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎα
σΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎαAnna Sakellaropoulou
 
Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936
Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936
Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936spetsiotou
 
臚ćșŠć€–科8æœˆć·2011
臚ćșŠć€–科8æœˆć·2011臚ćșŠć€–科8æœˆć·2011
臚ćșŠć€–科8æœˆć·2011Sakata Masatoshi
 

Andere mochten auch (20)

Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±
Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±
Developerたdeveloperă«ă‚ˆă‚‹developerぼためぼmetro designăźè©±
 
X.9 yuliana.ppt
X.9 yuliana.pptX.9 yuliana.ppt
X.9 yuliana.ppt
 
Kisah benar tragedi memali
Kisah benar tragedi memaliKisah benar tragedi memali
Kisah benar tragedi memali
 
PrÀsentation abwasser cem 40 a de
PrÀsentation abwasser cem 40 a dePrÀsentation abwasser cem 40 a de
PrÀsentation abwasser cem 40 a de
 
Premiere Reunion Publique
Premiere Reunion PubliquePremiere Reunion Publique
Premiere Reunion Publique
 
Roots, Stems, and Leaves Power Point
Roots, Stems, and Leaves Power PointRoots, Stems, and Leaves Power Point
Roots, Stems, and Leaves Power Point
 
Test communications
Test communicationsTest communications
Test communications
 
Spill Group 212 Event Final
Spill Group   212 Event FinalSpill Group   212 Event Final
Spill Group 212 Event Final
 
Legionnaires Disease
Legionnaires DiseaseLegionnaires Disease
Legionnaires Disease
 
Compromiso Familia y Escuela TIC 2.0
Compromiso Familia y Escuela TIC 2.0Compromiso Familia y Escuela TIC 2.0
Compromiso Familia y Escuela TIC 2.0
 
National library case study
National library case studyNational library case study
National library case study
 
Dma Competencies 2011 12
Dma Competencies 2011 12Dma Competencies 2011 12
Dma Competencies 2011 12
 
18.01.2 comparaison
18.01.2 comparaison18.01.2 comparaison
18.01.2 comparaison
 
Lambros Papayiannis presentation: whitefly viruses (in Greek)
Lambros Papayiannis presentation: whitefly viruses (in Greek)Lambros Papayiannis presentation: whitefly viruses (in Greek)
Lambros Papayiannis presentation: whitefly viruses (in Greek)
 
Ge fruehstuecken fit
Ge fruehstuecken fitGe fruehstuecken fit
Ge fruehstuecken fit
 
Powder coating oven
Powder coating ovenPowder coating oven
Powder coating oven
 
Message
MessageMessage
Message
 
σΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎα
σΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎασΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎα
σΔÎčσΌÎčÎșα ÎșυΌατα ÎčÏƒÏ„ÎżÏƒÎ”Î»ÎčΎα
 
Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936
Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936
Ύλη ÎŒÎ±ÎžÎ·ÎŒÎŹÏ„Ï‰Îœ Γ΄ ΓΔΜÎčÎșÎżÏ ΛυÎșÎ”ÎŻÎżÏ…, ÏƒÏ‡ÎżÎ». Î­Ï„ÎżÏ…Ï‚ 201314-, Ί.Ε.Κ.ÎČ 1936
 
臚ćșŠć€–科8æœˆć·2011
臚ćșŠć€–科8æœˆć·2011臚ćșŠć€–科8æœˆć·2011
臚ćșŠć€–科8æœˆć·2011
 

Ähnlich wie Chapter 05 show

Ppt lesson 09
Ppt lesson 09Ppt lesson 09
Ppt lesson 09Linda Bodrie
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 introJOSEPHINEA6
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5Akhil Mittal
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptNourhanTarek23
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.sagaroceanic11
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010Ali Mattash
 
PT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docxPT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docxamrit47
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editorputiadetiara
 
Visual Programming
Visual ProgrammingVisual Programming
Visual ProgrammingBagzzz
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesSami Mut
 
EX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - Instructi
EX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - InstructiEX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - Instructi
EX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - InstructiBetseyCalderon89
 
Gui builder
Gui builderGui builder
Gui builderlearnt
 
The Wear-Ever Shoes company maintains inventory data and custome.docx
The Wear-Ever Shoes company maintains inventory data and custome.docxThe Wear-Ever Shoes company maintains inventory data and custome.docx
The Wear-Ever Shoes company maintains inventory data and custome.docxpelise1
 
Sales force class-3
Sales force class-3Sales force class-3
Sales force class-3Amit Sharma
 

Ähnlich wie Chapter 05 show (20)

Ppt lesson 09
Ppt lesson 09Ppt lesson 09
Ppt lesson 09
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.ppt
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
PT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docxPT1420 Decision Structures in Pseudocode and Visual Basic .docx
PT1420 Decision Structures in Pseudocode and Visual Basic .docx
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editor
 
Visual Programming
Visual ProgrammingVisual Programming
Visual Programming
 
Winforms
WinformsWinforms
Winforms
 
Chapter - 6.pptx
Chapter - 6.pptxChapter - 6.pptx
Chapter - 6.pptx
 
Tugas testing
Tugas testingTugas testing
Tugas testing
 
06 procedures
06 procedures06 procedures
06 procedures
 
C# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slidesC# Tutorial MSM_Murach chapter-10-slides
C# Tutorial MSM_Murach chapter-10-slides
 
EX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - Instructi
EX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - InstructiEX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - Instructi
EX19_AC_CH03_GRADER_HOE_AS_InstructionsGrader - Instructi
 
Gui builder
Gui builderGui builder
Gui builder
 
The Wear-Ever Shoes company maintains inventory data and custome.docx
The Wear-Ever Shoes company maintains inventory data and custome.docxThe Wear-Ever Shoes company maintains inventory data and custome.docx
The Wear-Ever Shoes company maintains inventory data and custome.docx
 
Sales force class-3
Sales force class-3Sales force class-3
Sales force class-3
 
Excel300
Excel300Excel300
Excel300
 

KĂŒrzlich hochgeladen

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Christopher Logan Kennedy
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

KĂŒrzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Chapter 05 show

  • 2. Chapter 5: Decision Structures 2 Objectives Use the GroupBox object Place RadioButton objects in applications Display a message box Make decisions using If
Then statements Make decisions using If
Then
Else statements Make decisions using nested If statements
  • 3. Chapter 5: Decision Structures 3 Objectives Make decisions using logical operators Make decisions using Case statements Insert code snippets Test input to ensure a value is numeric
  • 4. Chapter 5: Decision Structures 4 Preview the Chapter Project
  • 5. Chapter 5: Decision Structures 5 Using the GroupBox Object Drag the GroupBox object in the Containers category of the Toolbox over the Form object to the approximate location where you want to place the GroupBox object When the mouse pointer is in the correct location, release the left mouse button. With the GroupBoxobject selected, scroll in the Properties window to the (Name) property. Double-click in the right column of the (Name) property and then enter the name grpWoodType Click to the right of the Size property of the GroupBox object and enter 125,100 as the size. Change the Font property to Goudy Old Style, Regular, Size 12. Change the BackColor property to White
  • 6. Chapter 5: Decision Structures 6 Using the GroupBox Object
  • 7. Using the GroupBox Object Chapter 5: Decision Structures 7
  • 8. Chapter 5: Decision Structures 8 Adding the RadioButton Objects Drag and drop one RadioButton object from the Toolbox into the GroupBox object on the Form object.Drag a second RadioButton object from the Toolbox into the GroupBox object, using blue snap lines to align and separate the RadioButton objects vertically Release the left mouse button to place the RadioButton object on the Form object within the GroupBox object. Using the same technique, add a third RadioButton object
  • 9. Chapter 5: Decision Structures 9 Adding the RadioButton Objects Name the RadioButton objects by selecting a RadioButton object, double-clicking in the right column of the (Name) property in the Properties window, and entering the name. The names for the radio buttons, from top to bottom, should be radPine, radOak, and radCherry Change the Text property for each RadioButton by double-clicking in the right column of the Text property and typing Pine for the first RadioButton, Oak for the second RadioButton and Cherry for the third RadioButton
  • 10. Chapter 5: Decision Structures 10 Adding the RadioButton Objects
  • 11. Adding the RadioButton Objects Chapter 5: Decision Structures 11
  • 12. Chapter 5: Decision Structures 12 Windows Application Container Objects
  • 13. Chapter 5: Decision Structures 13 Displaying a Message Box
  • 14. Chapter 5: Decision Structures 14 Displaying a Message Box
  • 15. Chapter 5: Decision Structures 15 Displaying a Message Box
  • 16. Chapter 5: Decision Structures 16 Displaying a Message Box
  • 17. Displaying a Message Box Chapter 5: Decision Structures 17
  • 18. Chapter 5: Decision Structures 18 Message Box IntelliSense In the code editing window, inside the event handler you are coding, type msgto display MsgBox in the IntelliSense list Press the Tab key to select MsgBox from the IntelliSense list. Type the following text: (“You have been disconnected from the Internet”, m) Select the MsgBoxStyle.AbortRetryIgnore argument by pressing the UP ARROW until the correct argument is highlighted.Type a comma.Then type "ISP” and a right parenthesis Click the Start Debugging button on the Standard toolbar
  • 19. Message Box IntelliSense Chapter 5: Decision Structures 19
  • 20. Chapter 5: Decision Structures 20 Displaying a Message Box
  • 21. Chapter 5: Decision Structures 21 Making Decisions with Conditional Statements: Using an If
Then Statement A decision structure is one of the three fundamental control structures used in computer programming When a condition is tested in a Visual Basic program, the condition either is true or false
  • 22. Chapter 5: Decision Structures 22 Relational Operators
  • 23. Chapter 5: Decision Structures 23 Relational Operators With the insertion point located in the correct location in the code, type ifand then press the SPACEBAR Type inta to select the variable named intAge in the IntelliSense list. Then, type >=18as the condition to be tested. Press the ENTER key On the blank line, enter the statement that should be executed when the condition is true. To place the message, “You are old enough to vote” in the Text property of the lblVotingEligibility Label object, insert the code shown in Figure 5-33 on page 315. Remember to use IntelliSense to reference the lblVotingEligibility Label object
  • 24. Relational Operators Chapter 5: Decision Structures 24
  • 25. Chapter 5: Decision Structures 25 Comparing Strings A string value comparison compares each character in two strings, starting with the first character in each string
  • 26. Chapter 5: Decision Structures 26 Comparing Different Data Types Every type of data available in Visual Basic can be compared Different numeric types can be compared to each other A single string character can be compared to a Char data type
  • 27. Using the If
Then
Else Statement Chapter 5: Decision Structures 27
  • 28. Chapter 5: Decision Structures 28 Using the If
Then
ElseIf Statement
  • 29. Nested If Statements Chapter 5: Decision Structures 29
  • 30. Nested If Statements Chapter 5: Decision Structures 30
  • 31. Chapter 5: Decision Structures 31 Matching If, Else, and End If Entries If statements must be fully contained within the outer If statement Place the correct statements with the correct If and Else statements within the nested If statement This illustration shows incorrect logic
  • 32. Testing the Status of a RadioButton Object in Code Chapter 5: Decision Structures 32
  • 33. Chapter 5: Decision Structures 33 Block-Level Scope Scope is defined by where the variable is declared within a program Within an event handler, an If
Then
Else statement is considered a block of code Variables can be declared within a block of code The variable can be referenced only within the block of code where it is declared
  • 34. Chapter 5: Decision Structures 34 Using Logical Operators When more than one condition is included in an If...Then...Else statement, the conditions are called a compound condition
  • 35. Using the And Logical Operator Chapter 5: Decision Structures 35
  • 36. Using the Or Logical Operator Chapter 5: Decision Structures 36
  • 37. Using the Not Logical Operator Chapter 5: Decision Structures 37
  • 38. Chapter 5: Decision Structures 38 Other Logical Operators
  • 39. Chapter 5: Decision Structures 39 Order of Operations for Logical Operators
  • 40. Chapter 5: Decision Structures 40 Select Case Statement In some programming applications, different operations can occur based upon the value in a single field
  • 41. Select Case Statement Chapter 5: Decision Structures 41
  • 42. Chapter 5: Decision Structures 42 Select Case Test Expressions
  • 43. Chapter 5: Decision Structures 43 Using Relational Operators in a Select Case Statement
  • 44. Using Ranges in Select Case Statements Chapter 5: Decision Structures 44
  • 45. Chapter 5: Decision Structures 45 Selecting Which Decision Structure to Use You might be faced with determining if you should use the Select Case statement or the If...Then...ElseIf statement to solve a problem Generally, the Select Case statement is most useful when more than two or three values must be tested for a given variable The If...Then...ElseIf statement is more flexible More than one variable can be used in the comparison Compound conditions with the And, Or, and Not logical operators can be used
  • 46. Chapter 5: Decision Structures 46 Code Snippets Right-click the line in the code editing window where you want to insert the snippet Click Insert Snippet on the shortcut menu Double-click the folder Code Patterns - If, For Each,Try Catch, Property, etc, which contains commonly used code such as the If . . . Then . . . Else statement Double-click the Conditionals and Loops folder because an If...Then...Else statement is a conditional statement Double-click the If...Else...End If Statement code snippet
  • 47. Chapter 5: Decision Structures 47 Code Snippets
  • 48. Code Snippets Chapter 5: Decision Structures 48
  • 49. Chapter 5: Decision Structures 49 Validating Data Developers should anticipate that users will enter invalid data Developers must write code that will prevent the invalid data from being used in the program to produce invalid output
  • 50. Chapter 5: Decision Structures 50 Testing Input to Determine If the Value Is Numeric The Visual Basic IsNumeric function can check the input value to determine if the value can be converted into a numeric value such as an Integer or Decimal data type
  • 51. Chapter 5: Decision Structures 51 Checking for a Positive Number
  • 52. Program Design Chapter 5: Decision Structures 52
  • 53. Program Design Chapter 5: Decision Structures 53
  • 54. Program Design Chapter 5: Decision Structures 54
  • 55. Chapter 5: Decision Structures 55 Chapter Summary Use the GroupBox object Place RadioButton objects in applications Display a message box Make decisions using If
Then statements Make decisions using If
Then
Else statements Make decisions using nested If statements
  • 56. Chapter 5: Decision Structures 56 Chapter Summary Make decisions using logical operators Make decisions using Case statements Insert code snippets Test input to ensure a value is numeric
  • 57. CHAPTER FIVE COMPLETE Decision Structures