Program that uses For: VB.NET Module Module1 Sub Main() ' This loop goes from 0 to 5. For value As Integer = 0 To 5 ' Exit condition if the value is three. If (value = 3) Then Exit For End If Console.WriteLine(value) Next End Sub End Module Output 0 1 2
Program that uses For Step: VB.NET Module Module1 Sub Main() ' This loop uses Step to go down 2 each iteration. For value As Integer = 10 To 0 Step -2 Console.WriteLine(value) Next End Sub End Module Output 10 8 6 4 2 0
出處
沒有留言:
張貼留言