1.Private Sub Form_Click()Dim i As Integer,k AsInteger,c As IntegerFor i = 1 To 5If i Mod 3 = 0 Thenk = k + 2Elsec = c + 3End IfNext iPrint k,cEnd Sub写出程序运行时单击窗体后,Form1上的输出结果.2.PrivateSub Form_Click()Static Sum A
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 18:44:32
1.Private Sub Form_Click()Dim i As Integer,k AsInteger,c As IntegerFor i = 1 To 5If i Mod 3 = 0 Thenk = k + 2Elsec = c + 3End IfNext iPrint k,cEnd Sub写出程序运行时单击窗体后,Form1上的输出结果.2.PrivateSub Form_Click()Static Sum A
1.Private Sub Form_Click()
Dim i As Integer,k AsInteger,c As Integer
For i = 1 To 5
If i Mod 3 = 0 Then
k = k + 2
Else
c = c + 3
End If
Next i
Print k,c
End Sub
写出程序运行时单击窗体后,Form1上的输出结果.
2.PrivateSub Form_Click()
Static Sum As Integer
For i = 1 To 6
Sum = Sum + i
Next i
Print Sum
EndSub
写出程序运行时点击窗体两次后,变量Sum的值.
3.PrivateSub Command1_Click()
Dim X As Integer,Y As Integer
X = 1 :Y = 1
For i = 1 To 3
For j = 1 To i
Y = Y + j
Next j
X = X + Y
Next i
Print X
EndSub
写出程序运行时单击命令按钮后,窗体Form1上的输出结果.
1.Private Sub Form_Click()Dim i As Integer,k AsInteger,c As IntegerFor i = 1 To 5If i Mod 3 = 0 Thenk = k + 2Elsec = c + 3End IfNext iPrint k,cEnd Sub写出程序运行时单击窗体后,Form1上的输出结果.2.PrivateSub Form_Click()Static Sum A
⒈ 2 12
⒉ 12
⒊ 19
前两个贴子的解释,参考:
http://zhidao.baidu.com/question/1795827046857966067.html
这里面二和三题的回复.
你的第3题:
外层循环i为1到3共3次循环,内层循环在这三次循环过程中,终值由i值决定.
i为1时,执行1次Y=Y+j,结束后Y就为2,然后X=X+Y,X值为3
i为2时,Y=Y+1+2,循环结束后Y就为5了,然后X=X+Y,X值为8
i为3时,Y=Y+1+2+3,循环结束后Y就为11了,然后X=X+Y,X值就为19了.
这时,最外层循环也结束.
X的最终值就是为19了.