Dim i As Integer,n As Integer For i = 0 To 50 i = i + 3 n = n + 1 If i > 10 Then Exit For Next PriDim i As Integer,n As IntegerFor i = 0 To 50i = i + 3n = n + 1If i > 10 Then Exit ForNextPrint n怎么算

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 22:07:20
DimiAsInteger,nAsIntegerFori=0To50i=i+3n=n+1Ifi>10ThenExitForNextPriDimiAsInteger,nAsIntegerFori=0To

Dim i As Integer,n As Integer For i = 0 To 50 i = i + 3 n = n + 1 If i > 10 Then Exit For Next PriDim i As Integer,n As IntegerFor i = 0 To 50i = i + 3n = n + 1If i > 10 Then Exit ForNextPrint n怎么算
Dim i As Integer,n As Integer For i = 0 To 50 i = i + 3 n = n + 1 If i > 10 Then Exit For Next Pri
Dim i As Integer,n As Integer
For i = 0 To 50
i = i + 3
n = n + 1
If i > 10 Then Exit For
Next
Print n
怎么算

Dim i As Integer,n As Integer For i = 0 To 50 i = i + 3 n = n + 1 If i > 10 Then Exit For Next PriDim i As Integer,n As IntegerFor i = 0 To 50i = i + 3n = n + 1If i > 10 Then Exit ForNextPrint n怎么算
实现效果,输出结果3
原理:
For i = 0 To 50
定义i从0循环到50
i = i + 3
这时i=0,所以其语句将原来的i值加上3
得3
n = n + 1
累加n
If i > 10 Then Exit For
判断i是否大于10,若是则跳出循环
第一次:
i=0
i=3
n=1
第二次:
i=3
i=6
n=2
第三次
i=6
i=9
n=3
第四次
i=9
i=12
i已大于10,跳出循环
输出n=3