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

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...