2018年1月4日 星期四

迴圈

迴圈
for next 
do....loop while  
do while......... loop


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i, sum As Short
        TextBox1.Text = ""
        sum = 0
        For i = 1 To 10
            sum = sum + i
            TextBox1.Text = TextBox1.Text & "i = " & i & " , Sum = " & sum & vbCrLf
        Next

    End Sub

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

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim i, sum As Short
        TextBox1.Text = ""
        sum = 0
        i = 0
        Do While (i <= 10)
            sum = sum + i
            i = i + 1
            TextBox1.Text = TextBox1.Text & "i = " & i & " , Sum = " & sum & vbCrLf
        Loop
    End Sub
End Class

沒有留言:

張貼留言

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

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