这段代码是错的,应该是这样:
MsgBox(Sum(3))‘这段代码可以验证一下N为3时的结果
Private Function Sum(ByVal N As Integer) As Long
Dim s As Long = 0
Dim i As Integer = 1
Do While i <= N
Dim j As Integer = 1
Dim s1 As Integer = 0
Do While j <= i
s1 += j
j += 1
Loop
s += s1
i += 1
Loop
Return s
End Function