Changes

Jump to: navigation, search

Visual Basic For Loops

382 bytes added, 18:51, 13 August 2007
no edit summary
<table border="0" cellspacing="0" width="100%"><tr><td width="20%">[[Visual Basic Flow Control|Previous]]<td align="center">[[Visual Basic Essentials|Table of Contents]]<td width="20%" align="right">[[Visual Basic Do ... Loops|Next]]</td><tr><td width="20%">Visual Basic Flow Control<td align="center"><td width="20%" align="right">Visual Basic Do ... Loops</td></table><hr>  Computers are incredibly good at repeating the same task over and over very quickly. One of the key functions of a programming language such as Visual Basic is to make it easy for a developer to program a computer to perform these repetitive tasks. Visual Basic provides a number of language structures which which tell a program to perform a task repeatedlytrepeatedly, either a specific number of times, or until certain conditions are met. In this chapter of Visual Basic essentials we will look at each of these in detail.
== Creating a Visual Basic For Loop ==
The Visual Basic ''For'' loop is ideal for situations wheer a task needs to be performed a specific number of times. For example, perhaps a value needs to be added to a variable 100 times. A Visual Basic ''For'' loop consists of a header, a code block and a next statement. The header copntains contains information about how many time times the loop is to be performed, the code block contains the statements to be executed on each iteration and the next statement sends the loop back to the header to repeat. The syntax of a ''For'' loop is as follows:
'''For''' ''counterVariable'' '''=''' ''fromValue'' '''To''' ''toValue''<br>

Navigation menu