- Version
- Download 64
- File Size 104.83 KB
- Create Date March 8, 2016
- Download
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