IterationUsing loops in VB.NET              1
Loop structuresThese are used when we want lines of codeto be executed many timesWe might want it to run a set number ofti...
Fixed Loop structuresIf we want the loop to run a fixed numberof times, we use a For…..Next loopThis will use a variable a...
For...Next example                     4
Conditional Loop StructuresIf we want the loop to repeat until acondition changes (at runtime).Use While …. End While to c...
While…End While example                          6
Conditional Loop StructuresUse Do…. Loop to run until a conditionbecomes trueThis code will run at least once Beware! It ...
Do… Loop Until example                         8
Programming termsWhen we need to repeat a set ofinstructions, we have 3 options: For….Next - runs for fixed number of loo...
Upcoming SlideShare
Loading in...5
×

Using loops

3,927

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,927
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using loops

  1. 1. IterationUsing loops in VB.NET 1
  2. 2. Loop structuresThese are used when we want lines of codeto be executed many timesWe might want it to run a set number oftimes.We may need to check if various conditionshave been met.There are loops for all occasions andprogrammers have their “favourites”! 2
  3. 3. Fixed Loop structuresIf we want the loop to run a fixed numberof times, we use a For…..Next loopThis will use a variable as a counterSyntax: For first value To last value Line of code to execute Next value 3
  4. 4. For...Next example 4
  5. 5. Conditional Loop StructuresIf we want the loop to repeat until acondition changes (at runtime).Use While …. End While to check thecondition before running loopSyntax: While condition = true Line of code execute End While 5
  6. 6. While…End While example 6
  7. 7. Conditional Loop StructuresUse Do…. Loop to run until a conditionbecomes trueThis code will run at least once Beware! It is possible to create loops that carry on to infinity. Press Ctrl + Break to stop, but you may lose some unsaved workSyntax: Do Line of code to execute Loop Until condition = true 7
  8. 8. Do… Loop Until example 8
  9. 9. Programming termsWhen we need to repeat a set ofinstructions, we have 3 options: For….Next - runs for fixed number of loops While…End While - runs while condition is true Do…Loop Until - runs until condition becomes true 9
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×