vb计算S=1*2+2*3+3*4+.N*(N+1)直到和大于5000停止,输出结果及N的值.

问题描述:

vb计算S=1*2+2*3+3*4+.N*(N+1)直到和大于5000停止,输出结果及N的值.

Private Sub Command1_Click()Dim N As Long,S As LongDoN = N + 1S = S + N * (N + 1)If S > 5000 Then Exit DoLoopPrint "结果=" & SPrint " N =" & NEnd Sub'结果=5200'N=24请参考.