1.编程:1+(1+2)+(1+2+3)+(1+2+3+4)+…(1+2+3+…N)+… DO While…Loop循环语句编写
1.编程:1+(1+2)+(1+2+3)+(1+2+3+4)+…(1+2+3+…N)+…DO While…Loop循环语句编写
程序代码:
Private Sub Command1_Click()
Dim i As Long, j As Long, k As Long, total As Long
total = 0: i = 0: j = 0: k = 0
Text1.Text = 0: Text1.Enabled = False
j = InputBox("Input Number ?")
Do While i < j + 1
For k = i To j
total = total + i
Next k
i = i + 1
Loop
Text1.Text = total
End Sub
