• Like
Loops
Upcoming SlideShare
Loading in...5
×
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
499
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
19
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. LOOPS
  • 2. Very Often, You Will Want to Do Something More Than Once HA HA HA HA HA HA HA HA HA HA HA HA
  • 3. You Could Code The ‘Ha Ha’ Like ThisConsole.WriteLine("Ha Ha ")Console.WriteLine("Ha Ha ") But is actually Lame!Console.WriteLine("Ha Ha ") No good programmerConsole.WriteLine("Ha Ha ") does this!Console.WriteLine("Ha Ha ")Console.WriteLine("Ha Ha ")Console.WriteLine("Ha Ha ")Console.WriteLine("Ha Ha ")
  • 4. Loops To The Rescue!• A loop is a piece of code which allows you to repeat some code more than once without having to write it out more than once. Do that 8 times! Console.WriteLine("Ha Ha ")
  • 5. COUNTER = 0 The FOR Loop For as long as thecounter isn’t 8 carry FOR loops stop on when their counter runs out Console.WriteLine("Ha Ha ") COUNTER + 1
  • 6. FOR Loops in VBModule Module1 Sub Main() Dim count As Integer For count = 1 To 8 Console.WriteLine("HA HA!") Next Console.ReadLine() End SubEnd Module
  • 7. STOP = no The WHILE LoopWhile stop is still no carry on WHILE may never stop! Console.WriteLine("Ha Ha ") STOP = yes
  • 8. Module Module1 WHILE Loops in VB Sub Main() Dim stopProgram As String stopProgram = "no" While stopProgram = "no" Console.WriteLine("HA HA!") Console.WriteLine("HA HA!") Console.WriteLine("HA HA!") Console.WriteLine("Do you want to stop?") stopProgram = Console.ReadLine() End While Console.WriteLine("GOODBYE!") Console.ReadLine() End SubEnd Module