# vb.net 教程 2-3 流程控制:循环语句 For...Next 2

for循环还可以指定循环的步长

For 初始值 To 结束值 Step 增量
执行语句块
Next

    Sub Main()
Dim i As Integer
Dim j As Integer = 0
For i = 0 To 21 Step 3
Console.WriteLine(i)
j += 1
Next
Console.WriteLine("循环次数：" & j)
End Sub

i=0执行一次，前进3个数，i=3执行，又前进3个数，i=6执行。。。，

    Sub Main()
Dim s As Integer
s = 0
For i As Integer = 1 To 99 Step 2
s += i
Next
Console.WriteLine(s)
s = 0
For i As Integer = 1 To 99
If i Mod 2 = 1 Then s += i
Next
Console.WriteLine(s)
End Sub