The Working of for loop by using vb.net with examples and explain its complete working.


Sub Main()
        Dim a As Integer

        For a = 1 To 10 Step 1
            Console.WriteLine("{0}", a & vbTab)

        Next
        Console.ReadLine()

    End Sub





Working of above program
In  above program FOR loop is used and this loop start from  1 and end at 10 we declare a variable (a) and assign 1 value to this variable when program is compiled and the working of loop is start loop is start from 1 and add 1 by using (step 1) this means 1 add to the value of a=1 when 1 is add to variable (a) then its value become a=2 in the same way  using for loop the output display counting from 1 to 10


Working of while loop with example in vb.net


Sub Main()
        Dim x As Integer
        x = 10
        While x > 5
            Console.WriteLine("{0}", x & vbTab)
            x = x - 1
        End While
      Con  sole.ReadKey()

    End Sub





Working of while loop by using  vb.et
  Sub Main()
        Dim x As Integer
        x =
1
    
    While x <= 49
            Console.WriteLine("{0}", x & vbTab)
            x = x + 1

        End While
        Console.ReadKey()

    End Sub







Working of above program
In  above program while loop is used and this loop start from  1 and end at 49 we declare a variable (a) and assign 1 value to this variable when program is compiled and the working of loop is start loop is start from 1 and add 1 by using (step 1) this means 1 add to the value of a=1 when 1 is add to variable (a) then its value become a=2 in the same way  using for loop the output display counting from 1 to 49










How we find even number by using for loop in vb.net





Sub Main()
        Dim a As Integer
        For a = 20 To 1 Step -2
            Console.WriteLine("{0}", a & vbTab)
        Next
        Console.ReadLine()

    End Sub









Working of above program
In  above program FOR loop is used and this loop start from  20 and end at 0 we declare a variable (a) and assign a=20 value to this variable when program is compiled and the working of loop is start loop is start from  20 and subtract 2 by using (step -2) this means  2 subtract t0 the value of a=20 when 2 is subtract  to variable (a) then its value become a=18 in the same way  using for loop the output display counting from 20 to 2 and display all the even number between the 0 to 20



 How nested loop is work in vb.net with example
Sub Main()
        Dim i, j As Integer
        For i = 1 To 5
            For j = 1 To i
                Console.WriteLine("{0}", i & vbTab)
            Next
        Next
        Console.ReadLine(
)
   
End Sub











How we convert do while loop to while loop

Sub Main()
        Dim a As Integer
        a = 0
        While a < 10
            Console.WriteLine("{0}", a & vbTab)
            a = a + 1
        End While
        Console.ReadLine()
    End Sub










Working of above program
In  above program FOR loop is used and this loop start from  0 and end at 10 we declare a variable (a) and assign 0 value to this variable when program is compiled and the working of loop is start loop is start from 0 and add 1 by using (step 1) this means 1 add to the value of a=1 when 1 is add to variable (a) then its value become a=1  the statement a=a+1 show that 1 is add into a and this value is assign to variable (a) in the same way  using for loop the output display counting from 0 to 9
















Post a Comment

  1. Why Do I Make Money From Online Bookmakers? - Work
    A bookmaker earns you หารายได้เสริม a commission when 룰렛 전략 you make 토토 사이트 코드 a bet, and you'll 슬롯 earn you money when you do it. However, bookmakers don't let you play 메이저 바카라 사이트

    ReplyDelete

Please give us feedback in comments here

 
Top