For Next Loop Statement

For Next Loop Statement executes a set of statements repeatedly in a loop for the given initial, final value range with the specified step by step increment or decrement value.

Syntax:
   For counter = start To end [Step]
      [Statement]
   Next [counter]
In the above syntax the Counter is range of values specified using the Start ,End parameters. The Step specifies step increment or decrement value of the counter for which the statements are executed.

Example:
 Private Sub Form1_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load
     Dim i As Integer
     Dim j As Integer
     j = 0
     For i = 1 To 10 Step 1
       j = j + 1
       MsgBox("Value of j is::" & j)
     Next i
 End Sub

No comments:

Post a Comment