Types+Of+Loops

=Types Of Loops= = = =__For Loops __=

 A for loop is used if you know how many times you want to go repeat the loop.

For example in VB

Dim count as Integer

For count = 1 to 5

console.WriteLine("Line{0}", count)

next

= = =<span style="background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: #aaaaaa; border-bottom-style: solid; border-bottom-width: 1px; color: black; font-size: 1.6em; font-weight: normal; line-height: 1.2em; margin-bottom: 0.1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-top: 0px; width: auto;">Repeat loop/while loop =

A repeat loop repeats until something is true. E.g If you are typing names in to a computer the loop will repeat until you type a key word to make it stop.

Here are two example in VB


 * __1. A do until loop__**

Do console.write(" enter a name, x to finish: ") Name = console.readLine Loop Until (Name = "X")

__**2. A do while loop**__

Do Console.write("Enter a name, X to finish: ") Name = Console.ReadLine Loop While (Name <> "X")

The next loop is like the opposite the loop does not start until the certain condition is met.

Do While Name <> "X"

Console.write("Enter a name, X to finish: ")

Name = Console.ReadLine

Loop