Chapter 61 Example : For … To… Step For index = 0 To n Step s lstValues.Items.Add(index) Next Control variable Start value Stop value Amount to add to.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Sample Dim i As Integer For i = 1 To 5 lstTable.Items.Add(i & " " & i ^ 2) Next The loop control variable, i, is Initialized.
Advertisements

 “Regular” variable ◦ Holds a single value ◦ For example Dim Student1 as String Dim Student2 as String Dim Student3 as String … Dim Studentn as String.
Example – calculating interest until the amount doubles using a for loop: will calculate up to 1000 years, if necessary if condition decides when to terminate.
Introduction to Computers and Programming Lecture 9: For Loops New York University.
CMPUT 101 Lab #6 October 29, :00 – 17:00. Array in C/C++ Array is a structure type variable. One dimension of array int: int num[3]; There are.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 6 Repetition Statements.
Chapter 6 - VB.Net by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops Peek Method Counters and Accumulators Flags.
Chapter 61 Flags A flag is a variable that keeps track of whether a certain situation has occurred. The data type most suited to flags is Boolean.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 6 Repetition Statements.
1 Python Chapter 4 Branching statements and loops © Samuel Marateck 2010.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 6 Repetition Statements.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
Adding and Subtracting Integers. RULE #1: Same Signs!! When you’re adding two numbers with the same sign, just ignore the signs! Add them like normal!
POSITIVE AND NEGATIVE NUMBERS
Objective: Learn to multiply and divide integers.
WHEN MULTIPLYING LIKE BASES, YOU ADD THE EXPONENTS FOR EXAMPLE: NOW YOU TRY:
Graphs of Functions Defined by Expressions in a Linear Equation On a standard screen, graph the following functions, determined from the given linear equation:
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
A dding two negative integers: add the absolute values the answer is negative Adding a negative and a positive number: subtract the absolute values the.
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and 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 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.
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
I CAN COMPARE AND ORDER RATIONAL NUMBERS BY USING A NUMBER LINE. 1.5 RATIONAL NUMBERS.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
More While Loop Examples CS303E: Elements of Computers and Programming.
Integers All whole numbers and their opposites including the number 0.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
Lesson 2-4. When adding positives: Add numbers Sign is positive Examples:
By Chad Blankenbeker.  The for-loop is best used when you know how many times it is going to be looped  So if you know you want it to only loop 10 times,
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
CSC 270 – Survey of Programming Languages C++ Lecture 6 – Exceptions.
Chapter 6 - VB.Net by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops Peek Method Counters and Accumulators Flags.
Count and add list of numbers From user input and from file.
6.2 For…Next Loops General Form of a For…Next Loop
Chapter 7 P 1 Lists and Loops List boxes and combo boxes List box - list of items - useful for a list which does not change Combo box - list of items -
Adding Integers Chapter 11-3.
Chapter 2 Lesson 3 Subtracting Integers pgs What you will learn: Subtract Integers Evaluate expressions containing variables What you will learn:
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study:
Subtracting Integers 7 th Grade Math Pg DART statement: I can subtract integers.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
مقدمة في البرمجة Lecture 7. Write VB.net project using the for loop to calculate : 1- the sum of numbers from 1 to (A) numbers. 2- the sum of Odd numbers.
5b – For Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
ALGEBRA TILES SOLVING EQUATIONS Replace the equation with tiles: Negative Positive -X X 1.
Solving Inequalities Using Addition & Subtraction.
Computer Science 101 For Statement. For-Statement The For-Statement is a loop statement that is especially convenient for loops that are to be executed.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Chapter 2 Integers and Introduction to Variables.
National Diploma Unit 4 Introduction to Software Development Data Structures – Loops and selection.
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.
Chapter 6 - VB 2008 by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study:
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study: Analyze a Loan.
Multiply Integers SWBAT multiply integers. Multiplication What is multiplication? What is multiplication? Repeated addition Repeated addition How do you.
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.
Dancing on Green Light.
Labs for week 2.
Repetition – For and Do While
2 Chapter Chapter 2 Integers and Introduction to Variables.
Week 8 - Programming II Today – more features: Loop control
Chapter (3) - Looping Questions.
3.1 Iteration Loops For … To … Next 18/01/2019.
CS150 Introduction to Computer Science 1
Chapter 6 - VB.Net by Schneider
8.4 Control of Multivariable Systems
CSC1401 Manipulating Pictures 2
To Start: 15 Points Evaluate: * 6 – 2 3(6 +2) – 2 3{6 +(3 * 4)}
Presentation transcript:

Chapter 61 Example : For … To… Step For index = 0 To n Step s lstValues.Items.Add(index) Next Control variable Start value Stop value Amount to add to index

Chapter 62 Example with Positive Step Dim j As Integer For j = 1 To 10 Step 2 lstBox.Items.Add(j) Next lstBox.Items.Add("Blastoff")

Chapter 63 Example with Negative Step Dim j As Integer For j = 10 To 1 Step -1 lstBox.Items.Add(j) Next lstBox.Items.Add("Blastoff")

Chapter 64 Non-integer Step Values Can lead to round-off errors with the result that the loop is not executed the intended number of times.

Chapter 65 Non-integer Step Example A loop beginning with For i As Double = 1 To 2 Step 0.1 will be executed only 10 times instead of the intended 11 times. It should be replaced with For i As Double = _ 1 To 2.01 Step 0.1

Chapter 66 Example A loop beginning with For i As Double = 1 To 2 Step 0.1 will be executed only 10 times instead of the intended 11 times. It should be replaced with For i As Double = _ 1 To 2.01 Step 0.1

Chapter 67 Lab 6.7 For Loop with Different Step Try Lab 6.7 to discover the characteristics of For … Next Loop