vb.net for loop code example

Example 1: vb for next

For index As Integer = 1 To 5
    Debug.Write(index.ToString & " ")
Next
Debug.WriteLine("")
' Output: 1 2 3 4 5

Example 2: for loop in vb.net

For a = 10 To 20 Step 2
          Console.WriteLine("value of a: {0}", a)
Next

Example 3: vb for loop

For variable As [Data Type] = start To end
// Statements to Execute
Next

=================Example=====================

  For i As Integer = 0 To 10
	Console.WriteLine("Counter: " & i)
  Next

Example 4: for loop vb.net

For counter [ As datatype ] = start To end [ Step step ]
    [ statements ]
    [ Continue For ]
    [ statements ]
    [ Exit For ]
    [ statements ]
Next [ counter ]

Tags:

Vb Example