General
Purpose Packages
Automated
Systems
Commercial Data
Processing
Computer Systems
Hardware
Computer Systems
Software
Programming Course
Arrangements

Loops: FOR ... NEXT

 

Repeating Code

Loops are used when an action is to be repeated in a program. .

IThe form below shows a picture box with the line "I like computing" repeated 10 times. This could be done by typing the same print commnand 10 times. However, using a loop would involve much less code, and it would be really easy to change the code to get the message to print 100, 1000 or even 1000000 times!

 

 

Play this video
Designing your programs! Go Full Screen to see in greater detail?

 

The For..Next loop starts with a FOR command that includes a variable to control how many times the loop is carried out. Think of this variable as a counter (why not call it counter?), because it keeps count of how many times the loop has ben carried out.

The loop ends with a simple NEXT command.

All lines of code between the FOR and the NEXT are carried out repeatedly until the required value is met in the control variable

 

 

 

What you have to do!

  1. Watch Movie 16 which shows how a LOOP can be included in a program to repeat a set of actions.
  2. Click the button to download the Simple Loop program. Make sure you choose Save
    Download Simple Loop
  3. Move the program to your VB Program folder. Right click on the zipped folder and choose Extract All or Extract Files. Click OK or Next and keep going until the process is Finished.
  4. Complete the display_message subroutine and check that the program works. You can choose any message you like to appear and should check that the program works for a loop going from 1 to 10 and also 1 to 100.
  5. Tick off your Progress Grids.

 

Mark off Exercise 12 in your progress grids.

 

 

What you MAY have to do!

Ask your teacher whether you should do the following task.

 

Assessment 3 (A3). Complete the assessment CAR STICKERS in your progress grids

 

 

What you should now be able to do!

 

Continue to Exercise 13: INPUT Boxes and Variables

 


 

 

 

 

Home | S1 Topics | S2 Topics
Computing Standard Grade | Info Systems Intermediate II | Info Systems Higher | Internet Safety
Log into Glow | School Website | Contact Us