SlideShare uma empresa Scribd logo
1 de 16
Excel Macros Level 1 Control Functions
Control Structures All applications can be written in terms of: Sequence Structures Selection Structures (or Selection Statements) Repetition Structures (or Repetition Statements) 4/29/2010 M. Campbell - 2010 2 p. 93
Flowchart Legend 4/29/2010 M. Campbell - 2010 3
Sequence Structures Typically built into language Allows statements to be executed one after another Add x and y together. Display the result. 4/29/2010 M. Campbell - 2010 4 p. 93
Selection Structures Allows code to be executed based on conditions If the number is even display it Otherwise, do not display it 4/29/2010 M. Campbell - 2010 5
Repetition Structures Allows code to be repeated as necessary While the number is less than or equal to 100, display it. Once it is over 100, end the program 4/29/2010 M. Campbell - 2010 6
The If…Then Statement Selection Statement: IfconditionThen ' statements go here ElseIfcondition2Then ' more statements Else ' more statements End If 4/29/2010 M. Campbell - 2010 7 p. 93
The For Loop Repetition Statement: Forcounter = startToend ' statements go here Nextcounter 4/29/2010 M. Campbell - 2010 8 p. 94
The For Loop By default a For loop: Sets counter to the value start Executes the code within the loop body Increments counter Continues looping until counter exceeds the end value Can use Exit For to leave For loop early 4/29/2010 M. Campbell - 2010 9 p. 95
The For Loop Can change the step size: Fori = 1 To 10 Step 2 ' code block goes here Nexti Can change the direction: Fori = 1 To 10 Step-5 ' code block goes here Nexti 4/29/2010 M. Campbell - 2010 10 p. 95
The For Each Loop Repetition Statement: For EachobjectVarIncollection ' code block goes here NextobjectVar 4/29/2010 M. Campbell - 2010 11 p. 96
The For Each Loop Loops through a collection of objects Each iteration places the next object in the variable objectVar 4/29/2010 M. Campbell - 2010 12 p. 96
The DoLoop Repetition Statement: Do While condition ' code block goes here Loop Repeats the code block while condition is true 4/29/2010 M. Campbell - 2010 13 p. 96
The DoLoop Repetition Statement: Do ' code block goes here Loop While condition Repeats the code block while condition is true Will execute at least once (as condition is checked last) 4/29/2010 M. Campbell - 2010 14 p. 96
The DoLoop Repetition Statement: Do Until condition ' code block goes here Loop Repeats the code block until condition becomes true 4/29/2010 M. Campbell - 2010 15 p. 96
The Select CaseStatement Selection Statement: Select Case testVar Case value1 ' code to execute if testVar = value1 Case value2 ' code to execute if testVar= value2 Case Else ' statements to execute otherwise End Select 4/29/2010 M. Campbell - 2010 16

Mais conteúdo relacionado

Semelhante a Unit 8: Control Statements

Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.net
ilakkiya
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
aprilyyy
 

Semelhante a Unit 8: Control Statements (20)

Unit 5: Variables
Unit 5: VariablesUnit 5: Variables
Unit 5: Variables
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
Conditional Statements & Loops
Conditional Statements & LoopsConditional Statements & Loops
Conditional Statements & Loops
 
03loop conditional statements
03loop conditional statements03loop conditional statements
03loop conditional statements
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.net
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
 
BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NET
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Ch05
Ch05Ch05
Ch05
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
Do...Loop
Do...LoopDo...Loop
Do...Loop
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Vb (2)
Vb (2)Vb (2)
Vb (2)
 
MidtermI-review.pptx
MidtermI-review.pptxMidtermI-review.pptx
MidtermI-review.pptx
 

Mais de Matthew Campbell, OCT

Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2
Matthew Campbell, OCT
 

Mais de Matthew Campbell, OCT (6)

Cleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your LoggingCleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your Logging
 
Building Bridges: A DevOps Story
Building Bridges:  A DevOps StoryBuilding Bridges:  A DevOps Story
Building Bridges: A DevOps Story
 
Happy Teams Make Better Code
Happy Teams Make Better CodeHappy Teams Make Better Code
Happy Teams Make Better Code
 
Real World Retrospectives
Real World RetrospectivesReal World Retrospectives
Real World Retrospectives
 
Unit 6: Functions and Subroutines
Unit 6: Functions and SubroutinesUnit 6: Functions and Subroutines
Unit 6: Functions and Subroutines
 
Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2
 

Último

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Unit 8: Control Statements

  • 1. Excel Macros Level 1 Control Functions
  • 2. Control Structures All applications can be written in terms of: Sequence Structures Selection Structures (or Selection Statements) Repetition Structures (or Repetition Statements) 4/29/2010 M. Campbell - 2010 2 p. 93
  • 3. Flowchart Legend 4/29/2010 M. Campbell - 2010 3
  • 4. Sequence Structures Typically built into language Allows statements to be executed one after another Add x and y together. Display the result. 4/29/2010 M. Campbell - 2010 4 p. 93
  • 5. Selection Structures Allows code to be executed based on conditions If the number is even display it Otherwise, do not display it 4/29/2010 M. Campbell - 2010 5
  • 6. Repetition Structures Allows code to be repeated as necessary While the number is less than or equal to 100, display it. Once it is over 100, end the program 4/29/2010 M. Campbell - 2010 6
  • 7. The If…Then Statement Selection Statement: IfconditionThen ' statements go here ElseIfcondition2Then ' more statements Else ' more statements End If 4/29/2010 M. Campbell - 2010 7 p. 93
  • 8. The For Loop Repetition Statement: Forcounter = startToend ' statements go here Nextcounter 4/29/2010 M. Campbell - 2010 8 p. 94
  • 9. The For Loop By default a For loop: Sets counter to the value start Executes the code within the loop body Increments counter Continues looping until counter exceeds the end value Can use Exit For to leave For loop early 4/29/2010 M. Campbell - 2010 9 p. 95
  • 10. The For Loop Can change the step size: Fori = 1 To 10 Step 2 ' code block goes here Nexti Can change the direction: Fori = 1 To 10 Step-5 ' code block goes here Nexti 4/29/2010 M. Campbell - 2010 10 p. 95
  • 11. The For Each Loop Repetition Statement: For EachobjectVarIncollection ' code block goes here NextobjectVar 4/29/2010 M. Campbell - 2010 11 p. 96
  • 12. The For Each Loop Loops through a collection of objects Each iteration places the next object in the variable objectVar 4/29/2010 M. Campbell - 2010 12 p. 96
  • 13. The DoLoop Repetition Statement: Do While condition ' code block goes here Loop Repeats the code block while condition is true 4/29/2010 M. Campbell - 2010 13 p. 96
  • 14. The DoLoop Repetition Statement: Do ' code block goes here Loop While condition Repeats the code block while condition is true Will execute at least once (as condition is checked last) 4/29/2010 M. Campbell - 2010 14 p. 96
  • 15. The DoLoop Repetition Statement: Do Until condition ' code block goes here Loop Repeats the code block until condition becomes true 4/29/2010 M. Campbell - 2010 15 p. 96
  • 16. The Select CaseStatement Selection Statement: Select Case testVar Case value1 ' code to execute if testVar = value1 Case value2 ' code to execute if testVar= value2 Case Else ' statements to execute otherwise End Select 4/29/2010 M. Campbell - 2010 16