Sunday, 22 July 2012

For loop in vb.net

This tutorial will introduce you to one of the first intermediate parts of the language, the For Loop. This loop will allow you to execute any code a certain amount of times. There are other types of loops which will be covered later on in the series. For loop is used to execute the statement given amount of time (given between two limits like for i=0 to 10) then the statement given in for loop execute 10 times. This is illustrate in below.

Copy and paste below Code:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim i As Integer = 0

        For i = 0 To 10
            MessageBox.Show("The value of i is: " & i)
        Next

    End Sub

End Class