Chapter 6 Controlling Program Flow with Looping Structures.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Advertisements

While loops.
Looping Structures: Do Loops
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
CS0004: Introduction to Programming Repetition – Do Loops.
CHAPTER 5: LOOP STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
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.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
Do Loops A Do..Loop terminates based on a condition that is specified Execution of a Do..Loop continues while a condition is True or until a condition.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
5.05 Apply Looping Structures
Chapter 5 new The Do…Loop Statement
CHAPTER 6 Loop Structures.
CHAPTER SIX.
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
110-K1 Iterations (1) Up to now, need to call the procedure again (e.g. click again on a command button) To repeat a piece of code: Can also use loops:
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
CIS 115 Lecture 8. There are 3 control structures common to most computer languages that determine the flow, or path of execution, of the code:  Sequential.
Chapter 12: How Long Can This Go On?
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1B) UTPA – Fall 2011.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 8: Chapter 5: Slide 1 Unit 8 List Boxes and the Do While Looping Structure.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Repetition Structures Repetition Structures allow you to write programs that will repeat program steps multiple times. –Also called Loops –Counter controlled.
JavaScript, Fourth Edition
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Chapter 7 - Lists, loops and printing w List boxes and combo boxes several types can add items at design time or during run time user select from predefined.
Review while loops Control variables Example Infinite loop
Looping Structures Do Loops, For Next Do...Loop While structures check the condition after executing the code and repeat a code block until the test.
Chapter 6 Looping Structures. Do…LoopDo…Loop Statement Can operate statements repetitively Do intx=intx + 1 Loop While intx < 10 –The Loop While operates.
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
Visual Basic Objects / Properties / Methods PropertyAdjective ObjectNoun Part of the application Attribute MethodVerb Action to do something.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
© 2006 Lawrenceville Press Slide 1 Chapter 6 The Post-Test Do…Loop Statement  Loop structure that executes a set of statements as long as a condition.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
Controlling Program Flow with Looping Structures
Controlling Program Flow with Decision Structures.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Looping Structures. A B dialog box that pops up and prompts the user for input Text area that pops up and prompts the user for to wait while it gets.
Loop Blocks Chapter 6 Part A. Program Blocks 1.Actions- commands, messages, methods 2.Branches- decisions to be made 3.Loops- actions to be repeated.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Chapter 5: Looping. Using the while Loop Loop – A structure that allows repeated execution of a block of statements Loop body – A block of statements.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
© 2010 Lawrenceville Press Slide 1 Chapter 5 The Do…Loop Statement  Loop structure that executes a set of statements as long as a condition is true. 
UNIT 5 Lesson 15 Looping.
Controlling Program Flow with Looping Structures
Lists, Loops, Validation, and More
3rd prep. – 2nd Term MOE Book Questions.
Repeating Program Instructions
Chapter 5 The Do…Loop Statement
Microsoft Visual Basic 2005: Reloaded Second Edition
Chapter (3) - Looping Questions.
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
CIS 16 Application Development Programming with Visual Basic
Do … Loop Until (condition is true)
Additional Topics in VB.NET
Prepared By: Deborah Becker
Presentation transcript:

Chapter 6 Controlling Program Flow with Looping Structures

6.1 The Do…Loop Statement Is a looping structure that executes a set of statements as long as a condition is True. Iteration – repeating one or more statements Example: Dim intNum As Integer intNum = 0 Do intNum = intNum + 2 ‘ Increment by 2 Loop While intNum < 10 (Do…Loop executes five times, on the fifth time Intnum = 10 making the condition false)

Do…Loop While The code in the loop must be executed at least once The condition determines if the loop will be repeated (True it repeats False it leaves the loop and continue on with the program).

Do While …Loop Different than the Do…Loop While The condition is evaluated first before entering the loop. If condition evaluates true the loop is entered. If the condition evaluates to false the loop is skipped. The code in the loop is not guarantee to be execute at all.

6.2 Infinite Loops Is a loop that does not stop running and never becomes false. CTRL + BREAK will stop an infinite loop if one occurs

6.3 Input Boxes Is a Visual Basic predefined dialog box that has a prompt, a text box, and OK and Cancel buttons. Used to get information from the user.

Input Boxes The InputBox form is –InputBox(prompt, title) –Prompt represents a string –Title represents a string –The InputBox will return a string so you will need to have a String memory variable to hold it or you can display it with the label.

Example of Code for the InputBox Dim strTextInput As String strTextInput = InputBox(“Enter Text”, “Input Box”) Or lblLabel.Caption = InputBox(“Enter text”, “Input Box”)