Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.

Slides:



Advertisements
Similar presentations
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Chapter 3 Programming Fundamentals Writing Code 3 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
Lecture 12 Another loop for repetition The while loop construct © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
Function.
5.05 Apply Looping Structures
Illuminating Computer Science CCIT 4-6Sep
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:
Chapter 3 Programming Fundamentals Writing Code 3 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
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.
Chapter 12: How Long Can This Go On?
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do While and Do Until Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Compunet Corporation1 Programming with Visual Basic.NET While, Do and For – Next Loops Week 5 Tariq Ibn Aziz.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
CHAPTER SIX LOOPS © Prepared By: Razif Razali 1. FORMAT OR REFRESH!! WHAT HAVE WE LEARN? Differentiate between the types of selection structure? Which.
Tutorial 6 The Repetition Structure
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
Chapter 4 Looping Statements Adapted From: Starting Out with Visual Basic 2008 (Pearson)
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
CW-V1 SDD 0901 Principals of Software Design and Development Loops Starter: Water JugsWater Jugs.
Visual Basic Programming I 56:150 Information System Design.
Counting Loops.
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.
Control Your Application Sequence, Selection, and Repetition.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
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
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
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()
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
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.
MIC305 Week 6 Beyond controls Review of properties Differences with VB6: using classes and instances Programming constructs.
1 VB-04-Control Structures 16 March 2016 Visual Basic Control Structures - Selection.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Chapter 6 Controlling Program Flow with Looping Structures.
Chapter 5 - VB 2008 by Schneider1 Chapter 5 – Repetition 5.1 Do Loops 5.2 Processing Lists of Data with Do Loops 5.3 For...Next Loops.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Chapter 5- Control Structures: Part 2
Visual Basic 6 (VB6) Data Types, And Operators
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Problem Solving and Control Statements: Part 2
Control Structures: Part 2
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.
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Control Structures: Part 1
حلقات التكرار.
Fundamentals of visual basic
Case & Repetitive Statements
Prepared By: Deborah Becker
Chapter 3 Programming Fundamentals
Presentation transcript:

Statements That Repeat

For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if less than end. If so, repeat loop again. If not, go to statement after Next.

Do While...Loop Structure Do While condition statements Loop Where The condition is tested, and if true the loop is repeated. When the condition is false, the loop statements are skipped the statement after Loop is executed.

Do Until...Loop Structure Do Until condition statements Loop Where The condition is tested, and if false the loop is repeated. When the condition is true, the loop statements are skipped the statement after Loop is executed.

‘Calculate the factorial of a number given by user Dim Factorial As Double Dim I As Integer I = 1 Factorial = 1 Do While I <= Val (txtAnswer.text) Factorial = Factorial + 1 I = I + 1 Loop Do Until...Loop Structure User gives number

Loops with the Marching Band Project Hands-On Exercise 3 (P ) –Create the Marching Band Project –Add Command Buttons and a Timer –Add Controls to Display the Band –Add Banner Comments –Add Code for Buttons and the Form –Add Code to Add Animation –Run, Save, Test and Debug Your Project –Create a Copy of the Project –Change Animation Code –Update, Run, Save, Test and Debug –Exit Visual Basic

Summary... Fundamental programming demonstrated Variables vs. Constants Data types Local vs Global variables Functions and Procedures Control structures: sequence, selection and repetition

Summary Statements –Dim, Static, Const –Public, Private –Sub, Function –Do...Loop, Do While...Loop, Do Until...Loop –For Each...Next, For...Next –If...Then...Else –Select Case

Practice with Visual Basic 1. Learning to Subtract Game (P.148) 2. Wind Chill in Celsius (P.148) 3. Heat Index (P.148) 4. Rock, Paper, Scissors Game(P.150)

Case Studies Calculate a Formula Weather Calculations More Fun and Games More Web Resources for Visual Basic

End of Lecture