主题:两道循环部分的习题怎么做?
wulei0301
[专家分:0] 发布于 2010-12-04 22:05:00
我在循环这一部分有两道习题做不出来,希望朋友们帮帮忙,谢谢了!
回复列表 (共5个回复)
沙发
一江秋水 [专家分:9680] 发布于 2010-12-05 10:55:00
Private Sub Command1_Click()
Dim N As Long, A As Long, B As Long
N = 1
Do
A = A + N ^ N
If A < 10000 Then N = N + 1: B = A Else Exit Do
Loop
Debug.Print B
End Sub
板凳
wulei0301 [专家分:0] 发布于 2010-12-05 23:17:00
谢谢
3 楼
孙瑞 [专家分:590] 发布于 2010-12-06 16:30:00
建议秋水大哥加上“DoEvents”
4 楼
老大徒伤悲 [专家分:29120] 发布于 2010-12-07 08:34:00
似乎不需要,和不大于一万循环补了几次的
5 楼
feitianzhu1000 [专家分:0] 发布于 2010-12-12 11:36:00
Private Sub Command1_Click()
Dim sum As Long
Dim i As Integer
Dim sum1 As Long
sum = 0
sum1 = 0
i = 1
Do
sum1 = sum1 + i ^ i
If sum1 < 10000 Then
i = i + 1
sum = sum1
Else
Exit Do
End If
Loop
Print sum
Print i
End Sub
我来回复