Professional Documents
Culture Documents
Repetition Structure: Lesson 2: Using Loops
Repetition Structure: Lesson 2: Using Loops
Repetition Structure: Lesson 2: Using Loops
REPETITION
STRUCTURE
Lesson Objectives
Define repetition control structure
Understand the program logic of each
type of repetition structure
Recognize the VB statements that are
used to implement the different
repetition structure
Create VB program using loop
statements
Repetition Structure
Also known as iteration or looping
structure.
Directs the computer to repeat one or
more instructions based on the value of
condition
Loop
Is one of the most important structure of
in programming because it allows the
programmer to create instructions that
will be repeated a number of times
without bloating the program code.
Loop Statements:
For Next
Do
Nested Loop
FOR NEXT STRUCTURE
Also known as the For Loop structure.
Contains a group of statements that are
repeated at specific number of times.
It tests the condition at the beginning of
the loop and executes the statements
contained in the loop as long as the
condition returns a True value.
FOR NEXT STRUCTURE
Counter
FALSE
Compari
son test
Statement 3
TRUE
Statement 1
Statement 2
FOR NEXT STRUCTURE
Counter = 1
FALSE
Counter
<=5 Print “Done”
TRUE
Print “Tracy”
Counter =
Counter + 1
SAMPLE PROBLEM
Problem Definition
Create a program that will display the
numbers from 1 through 10.
Program Objective
The program will set the initial value of the
number to 1. It will test if the number is less
than or equal to ten. If the result is true the
program will display the number and
increase the number by 1. It will repeat the
process of testing, display, and increasing
the number until the value of the number is
greater than 10.
IPO
INPUT PROCESS OUTPUT
FALSE
Number
<=10
Stop
TRUE
Number =
Number + 1
Display
Number