Translate

Wednesday 12 June 2013

For Loop in VB.NET

In this Blog I will show you loop. If want to do an action repeatedly you can use loop. VB.NET have 3 types of loop first we will see For loop in this blog other two loops will see later.


 Module Example11
    Sub main()
        Dim val As Integer
        For val = 1 To 10
            Console.WriteLine(val)
        Next
        Console.ReadKey()
    End Sub
End Module

The above example shows how For loop is used to display numbers from 1 to 10 the value starts from 1 displays using Console.Writeline statement  and moves to Next statement the next statement increase the val from 1 to 2 likewise it keeps on increasing the val  by 1 if the val reaches 11 the loop finishes and Console.Readkey() will execute.

No comments:

Post a Comment