vb编一个计算1+2+3+4+...+100=的程序

运用计数循环结构
2024-12-21 16:07:21
推荐回答(2个)
回答1:

Dim sum As Integer, i As Integer
sum = 0
For i = 1 To 100
sum = sum + i
Next
Debug.Print "1 + 2 + ... + 100 ="; sum

回答2:

Private Sub Command1_Click()
Dim a As Integer
For i = 1 To 100
a = a + i
Next
Print a
End Sub