VB SCRIPT LOOPING

VB script looping




               Looping statement are used to run the same block of code a specified number of times.

  • For...Next statement
  • For..Each...Next statement
  • Do...loop statement
  • while..wend statement

For..Next loop:


    Use the For...Next statement to run a block of code a specified number of times.

The For statement specifies the counter variable and its start and end value.
The Next statement increase the counter variable by one

Example:

For i=2 To Step 2
some code
Next


For each ...next loop:


    A For Each ...Next loop repeats a block of code for each item in a collection or for each element of an array.


Do..loop:


      The Do...loop statement repeats a block of code while a condition is true or until a condition becomes true.Repeat code while a condition is true you use the while keyword to check a condition in a do.. loop statement.


Example:


Do
 some code
Loop Until i=10


While ...Wend loop:


    In a while ..wend loop if the condition is true all statement are executed until wend keyword is encountered.If the condition is false the loop is exited and the control jumps very next statement after wend keyword

Syntax:


while condition(s)
statement
wend

Post a Comment

0 Comments