Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.

Slides:



Advertisements
Similar presentations
Looping Structures: Do Loops
Advertisements

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.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Chapter 6: The Repetition Structure
CS0004: Introduction to Programming Repetition – Do Loops.
Repeating Actions While and For Loops
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
Do Loop The syntax of DO loop: DO variable = initial_value, final_value[, increment] [statements] END DO Example: PROGRAM LINES ! Illustration of DO-loops.
Loops Counting down from N to 1 in assembly we used JUMP statements to repeat previous instructions thus looping READ LOOP: WRITE SUB decrement JPOSLOOP.
For Next Looping My first Looping Structure. For…Next FOR counter_variable = initial_value TO end_value STEP increment Statement-1 Statement-2 ……. Statement-n.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
Chapter 6 - Visual Basic Schneider
1 Principles of Software Design and Development LOOPS / REPITITION.
INTRODUCTION TO PYTHON PART 3 - LOOPS AND CONDITIONAL LOGIC CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
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:
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 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.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
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 Programming
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
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)
6.2 For…Next Loops General Form of a For…Next Loop
A loop is a repetition control structure. body - statements to be repeated control statement - decides whether another repetition needs to be made leading.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program 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.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Chapter 8 P 1 Arrays and Grids Single-dimension arrays Definition An array is a sequence of elements all referred to with a common name. Other terms: table,
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
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
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
5b – For Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
National Diploma Unit 4 Introduction to Software Development Data Structures – Loops and selection.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
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.
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 9 Repetition.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Clearly Visual Basic: Programming with Visual Basic nd Edition
Visual Basic 6 (VB6) Data Types, And Operators
Lists, Loops, Validation, and More
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 5 Repetition.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Chapter 9 Control Structures.
Chapter (3) - Looping Questions.
Computer Science Core Concepts
Looping and Multiple Forms TEST REVIEW
PROGRAM FLOWCHART Iteration Statements.
Presentation transcript:

Visual Basic.net Loops

Used to do multiple executions of the same block of code Do while loops Do until loops For next loops

Do while loop (Syntax) Do while (condition) [loop instructions] Loop

Do while loop (example) Dim intCount as Integer ‘ declare local variable Intcount = 1 ‘ initialing counter to 1 Do while intCount <= 3 ‘ loop while count is <= 3 Print intCount ‘ print intCount to the printer intCount = intCount + 1 ‘ add 1 to intCount Loop ‘ redo the block of code until false

Do while (Flowchart) Start Declare intCount variable intCount = 1 intCount <= 3 Stop Display intCount intCount = intCount + 1 T

Do until loop (Syntax) Do [loop instructions] Loop until (condition)

Do until (example) Dim intCount as Integer ‘ declare a local variable intCount = 1 ‘ initializing counter to 1 Do ‘ redo block of code until false Print intCount ‘ print intCount to the printer intCount = intCount + 1 ‘ add 1 to intCount Loop until intCount > 3 ‘ loop until > 3

Do until (Flowchart) Start Declare intCount variable intCount = 1 Display intCount intCount = intCount + 1 intCount > 3 Stop T F

For Next Loop AKA an automatic counter loop Repeats a block of code statements a specified number of times

For Next (Syntax) For counter = startvalue to endvalue [Step stepvalue] [instructions] Next counter

For Next (Example) For intCount = 1 to 3 Step 1 ‘ initializing Print intCount ‘ prints out intCount Next intCount‘ loop

For Next (Flowchart) Start Declare intCount variable For for next loop Print intCount Stop 1 >3 intCount 1