急!!!!VB编程求1加到100的和,5种方法!!!!!
急!!!!VB编程求1加到100的和,5种方法!!!!急要,所以分高5种方法分别要对应5种循环方式...
急!!!!VB编程求1加到100的和,5种方法!!!!
急要,所以分高
5种方法分别要对应5种循环方式 展开
急要,所以分高
5种方法分别要对应5种循环方式 展开
1个回答
展开全部
Option Explicit
Private Sub Command1_Click()
Dim i As Integer, s As Integer
For i = 1 To 100
s = s + i
Next
Print s
End Sub
Private Sub Command2_Click()
Dim i As Integer, s As Integer
Do While i <= 100
s = s + i
i = i + 1
Loop
Print s
End Sub
Private Sub Command3_Click()
Dim i As Integer, s As Integer
Do
i = i + 1
s = s + i
Loop While i <= 99
Print s
End Sub
Private Sub Command4_Click()
Dim i As Integer, s As Integer
While i <= 100
s = s + i
i = i + 1
Wend
Print s
End Sub
Private Sub Command5_Click()
Dim i As Integer, s As Integer
GOTONEXT:
s = s + i
i = i + 1
If i <= 100 Then GoTo GOTONEXT
Print s
End Sub
Private Sub Command1_Click()
Dim i As Integer, s As Integer
For i = 1 To 100
s = s + i
Next
Print s
End Sub
Private Sub Command2_Click()
Dim i As Integer, s As Integer
Do While i <= 100
s = s + i
i = i + 1
Loop
Print s
End Sub
Private Sub Command3_Click()
Dim i As Integer, s As Integer
Do
i = i + 1
s = s + i
Loop While i <= 99
Print s
End Sub
Private Sub Command4_Click()
Dim i As Integer, s As Integer
While i <= 100
s = s + i
i = i + 1
Wend
Print s
End Sub
Private Sub Command5_Click()
Dim i As Integer, s As Integer
GOTONEXT:
s = s + i
i = i + 1
If i <= 100 Then GoTo GOTONEXT
Print s
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询