top of page

Public Class Form56

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

       

        'For... Next... Looping Procedure 
        'Loop until If Test... Then End If Equals Condition 

        Me.ListBox1.BackColor = Color.LightBlue
        Me.Label1.BackColor = Color.LightBlue
        Me.Label2.BackColor = Color.LightGreen

        Dim Counter, Sum As Integer


        For Counter = 1 To 100
            Sum = (Sum + Counter)
            ListBox1.Items.Add(
"Count = " & Counter & " Sum = " & Sum)
            If Sum >= 3160 Then
                GoTo line2


            End If
        Next

Line2:  Label1.Text = "Counter = " & Counter
        Label2.Text =
"For... Next Statement Condition = " & Sum

    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click

        Me.ListBox1.BackColor = Color.LightGreen

        'Do... While... Looping = Condition 

        Dim Counter, Sum As Integer

        'Do While Statement Conditions are Smaller or Equal to Value 

        Do While Sum <= 3081
            Counter = (Counter + 1)
            Sum = (Sum + Counter)
            ListBox1.Items.Add(
"Count = " & Counter & " Sum = " & Sum)


        Loop

        Label1.Text = "Counter = " & Counter
        Label2.Text = "Do While... Loop Condition Smaller or Equal to " & Sum

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        ListBox1.Items.Clear()
        Label1.Text = ""
        Label2.Text = ""

    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click

        Me.ListBox1.BackColor = Color.LightBlue

        'Do... While... Looping = Condition 

        Dim Counter, Sum As Integer

        'Do Until Conditions are Equal to Value 

        Do Until Sum = 3160 'Note Eliminating the [<] in <= Initiates the Program 
            Counter = (Counter + 1)


            Sum = (Sum + Counter)
            ListBox1.Items.Add(
"Count = " & Counter & " Sum = " & Sum)


        Loop

        Label1.Text = "Counter = " & Counter
        Label2.Text = "Do Until... Loop Condition = " & Sum

    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click

        Me.ListBox1.BackColor = Color.LightGreen

        'While ... End While Condition 

        Dim Counter, Sum As Integer


        'Loop [While] Conditions are Smaller than Value 

        While Sum < 3160
            Counter = (Counter + 1)
            Sum = (Sum + Counter)
            ListBox1.Items.Add(
"Count = " & Counter & " Sum = " & Sum)
        End While     
'End While Conditions are met 

        Label1.Text = "Counter = " & Counter
        Label2.Text =
"While... End While Condition Smaller " & Sum


    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        Form49.Show()
        Me.Hide()

    End Sub
End Class

bottom of page