Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6)

Slides:



Advertisements
Similar presentations
Chapter 6: The Repetition Structure
Advertisements

JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
Repeating Actions While and For Loops
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
1 Principles of Software Design and Development LOOPS / REPITITION.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Embedding Videos. Adding Videos to Our Website: Videos can make our pages more interesting and engaging. Most video-hosting websites, such as YouTube,
New ways of learning week Sign up at: Monday 25 th November Tuesday 26 th November Wednesday 27 th November Thursday.
Pseudo Code Possibly one of the hardest skills to get to grips with in learning a programming language is developing the ability to take a problem and.
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.
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Tutorial 6 The Repetition Structure
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.
PROGRAMMING ITERATION 2. Starter  Put the following code in order (write down the line numbers).  The program should display the numbers 1-24 on screen.
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
Structured Programming Constructs March, 2011Copyright Yvette Francis.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
CSCI 171 Presentation 5. The while loop Executes a block as long as the condition is true general form: while (condition) { statement 1; statement 2;
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
CW-V1 SDD 0901 Principals of Software Design and Development Loops Starter: Water JugsWater Jugs.
For Code Next For Code Next A loop is a segment of a code that repeats (changing slightly each time)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Teacher Functions. Teacher Functions in OAS Create Tests Assign Tests to a Class View Reports of Student Performance.
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
BO65: PROGRAMMING ITERATION 1. Starter  Write down what you think the code below outputs on screen: Dim intCounter as integer intCounter = 0 Do while.
MTH 231 Section 5.2 Addition and Subtraction of Integers.
FOR LOOPS "LOOP FOR A SET NUMBER OF TIMES.". FOR ( START_VALUE; END_VALUE; INCREMENT_NUMBER ) { //YOUR_CODE_HERE } So after the word "for" (in lowercase)
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
SCORE Sequence Choices to be made Once may not be enough Reuse and recycle Evaluate and improve.
Loops Tonga Institute of Higher Education. Introduction Programs need to be able to execute tasks repeatedly. Use loops to repeat actions  For Loop 
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 9: Chapter 5: Slide 1 Unit 9 Do Until and For… Next Loops Chapter 5 Lists,
Loops ISYS 350. Write a Program that asks user to enter any numbers and displays the largest number Process: Largest = the first number Get the next number.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
CE En 270 Brigham Young University Norm Jones
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.-Edited By Maysoon Al-Duwais1.
Games Programming in Scratch
Clearly Visual Basic: Programming with Visual Basic nd Edition
Containers and Lists CIS 40 – Introduction to Programming in Python
Lecture 6 Repetition Richard Gesick.
Lists, Loops, Validation, and More
CS1371 Introduction to Computing for Engineers
Counted Loops.
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
الحلقات التكرارية وجمل الدوران (loops)
Teacher Functions.
Standard Algorithms Input validation Finding the minimum
Java Programming Loops
Looping and Random Numbers
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Welcome back to Software Development!
Computer programming Lecture 3.
Multiplying and Dividing Integers
More Loops Topics Counter-Controlled (Definite) Repetition
Introduction to Repetition
ASP control structure BRANCHING STATEMENTS
More Loops Topics Counter-Controlled (Definite) Repetition
Introduction to Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
Presentation transcript:

Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6) lstTest.Items.Add(7) lstTest.Items.Add(8) lstTest.Items.Add(9) lstTest.Items.Add(10)

S.C.O.R.E Sequence your tasks Choose your options Once may not be enough Recycle and reuse Evaluate and improve

Types of Loops Type 1For Next Loop LogicRepeats a section of code a specified number of times. So if we wanted to do a task 1000 times, this kind of loop is ideal. Type 2While Loop LogicRepeats a section of code until a certain condition is met, that is the condition may be met on the first attempt or on the thousandth, we simply don’t know! For example we might want to delete all inactive members of a video club so long as there are any left to delete. Type 3Do Loop LogicRepeats the code once then continues until a certain condition is met. For example a student may study one or more modules and each module needs a start date. Since a student must have at least one module we are guaranteed to do at least one item of processing, but we don’t know how many modules a student is studying so the loop will end only when all modules are processed.

The For Next Loop For any loop to work we need to know three things… When the loop will start When the loop will end Where the loop is up to at a given point

The Load Event

DisplayWishList

Step For Counter = 1 to 5 Step 2 'code here Next Would loop three times, through the values 1, 3 and 5. Step forces the loop (in this example) to make increments of 2. What does the following code do?... For Counter = 5 to 1 Step -1 'code here Next

Questions 1. Complete the code for the following For Next loop so that it starts with a value of 1 and ends with 10: Dim Counter as Integer For Counter = _____ To _____ 'code here Next

Questions 2. What will be the value of Temp? Dim StartValue As Integer Dim EndValue As Integer Dim Counter As Integer Dim Temp As Integer StartValue = 10 EndValue = StartValue * 2 Temp = 0 For Counter = StartValue To EndValue Temp = Temp + 1 Next

Questions 3. Write a For Next Loop that counts from 50 to Write a For Next Loop that counts from 10 to 0 in steps of 2.