Looping

Overview

Looping is one of the most important flow-control mechanisms in a programming language. Looping constructs provide the foundation for any application that must repetitively perform a task, such as adding 1 to a variable, reading a text file, or processing an e-mail message and sending it.

Code Tour

VBScript and JScript provide several looping mechanisms. This sample demonstrates the three most commonly used looping statements, For ... Next, Do ... Loop, and While ... Wend. These three statements are subtly different, and the scripting situation will frequently dictate which of the three would work best. For the purpose of this sample, however, each type of looping statement is used to accomplish the same task, which is to print a greeting five times using progressively larger font sizes. For each looping statement, the variable i is initialized, and the test condition for the loop is defined such that i will never be greater than 5. The variable is then incremented by 1 for each iteration of the loop.

Location

The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\simple\Looping_VBScript.asp and ...\asp\simple\Looping_JScript.asp.