一道VB程序题。求结果。Private Sub Form_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer
k = 1
For i = 11 To 2 Step -3
For j = 7 To 1 Step -2
j = j - 1
k = k + 1
Next j
If i < 5 Then Exit For
Next i
Print i, j, k
End Sub
求问k为什么会加12次1?
追答i的值:11 8 5 2,最后因为 If i < 5 Then Exit For 直接退出循环
每一轮内循环结束时 j 的值:6 3 0,循环后再加一个Step后 j 的值就是-2
所以,是加了4*3=12次
多谢