Loops in Visual Basic .Net

Loops in Visual Basic .Net
  • Version
  • Download 64
  • File Size 104.83 KB
  • Create Date March 8, 2016

Loops in Visual Basic .Net

Different Types of Loop in Visual Basic .Net

Types of loop included in this program:
Do
Do while
Do until
For loop

Source code:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myNumber As Integer = 0
        Do
            myNumber = myNumber + 1
            MessageBox.Show(myNumber)
            If myNumber = TextBox1.Text Then Exit Do
        Loop
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim myNumber As Integer = 0
        Do While myNumber < TextBox1.Text myNumber = myNumber + 1 MsgBox(myNumber) Loop End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim myNumber As Integer = 0 Do Until myNumber > TextBox1.Text
            myNumber = myNumber + 1
            MsgBox(myNumber)
        Loop
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim myNumber As Integer = 0
        For myNumber = 1 To TextBox1.Text
            MsgBox(myNumber)
        Next myNumber
    End Sub
End Class
, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.