2018年1月4日 星期四

巢狀迴圈




Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i, j, P As Short
        For i = 1 To 9
            For j = 1 To 9
                P = i * j
                TextBox1.Text = TextBox1.Text & i & "*" & j & "=" & P & "   "
            Next
            TextBox1.Text = TextBox1.Text & vbCrLf
        Next

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim i, j, P As Short
        i = 1
        j = 1
        Do While (i <= 9)
            Do While (j <= 9)
                P = i * j
                TextBox1.Text = TextBox1.Text & i & "*" & j & "=" & P & "   "
                j = j + 1
            Loop
            TextBox1.Text = TextBox1.Text & vbCrLf
            j = 1
            i = i + 1
        Loop

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim i, j, P As Short
        i = 1
        j = 1
        Do
            Do
                P = i * j
                TextBox1.Text = TextBox1.Text & i & "*" & j & "=" & P & "   "
                j = j + 1
            Loop While (j <= 9)
            TextBox1.Text = TextBox1.Text & vbCrLf
            j = 1
            i = i + 1
        Loop While (i <= 9)

    End Sub

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

        Dim i, j, P As Short
        j = 1
        For i = 1 To 9
            Do
                P = i * j
                TextBox1.Text = TextBox1.Text & i & "*" & j & "=" & P & "   "
                j = j + 1
            Loop While (j <= 9)
            TextBox1.Text = TextBox1.Text & vbCrLf
            j = 1
        Next

    End Sub
End Class

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...