close
當程式執行時,需要將某個敘述區段執行多次時,便可使用For…Next或是Do….Where等敘述。
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For index As Integer = 1 To 100000 '計數變數宣告為index
If index >= 3 And index <= 8 Then
Continue For '如果滿足以上兩條件則跳回迴圈
End If
ListBox1.Items.Add(index)
If index = 10 Then
Exit For
End If
ListBox2.Items.Add(index)
Next
End Sub
End Class
全站熱搜