一道vb题1!-2!···

题目:(事件)单击窗体。
(响应)已知sum=1!-2!+3!-4!···-10!
将sum结果值输出到窗体上。
实用do while···loop语句完成程序
答对我会增加财富值的!!谢谢

Private Sub Form_Click()
Dim sum As Integer, a As Integer, fact As Integer
a = 1
sum = 1
fact=a
Do While a <10
a=a+1
fact=fact*a
sum=sum+(-1)^(a-1)*fact
Loop
Print "计算结果是:" ; sum
End Sub

Ps:这应该自己想一下的,这不算难,几句就可搞定来自:求助得到的回答
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-12-30
Private Sub Form_Click()
Dim j As Double, sum As Double, n As Integer, fh as integer
j = 1
n = 1
fh = 1 '控制符号,第一为1 ,n=2时为-1
Do While n <= 10
j = j * n
sum = sum + j * fh
fh = - fh
n = n + 1
Loop
Print sum
End Sub本回答被网友采纳
第2个回答  2012-12-30
Private Sub Form_Click()
Dim jc As Double, sum As Double, n As Integer
jc = 1
n = 1
Do While n <= 10
jc = jc * n
sum = sum + jc
n = n + 1
Loop
Print sum
End Sub
第3个回答  2012-12-30
Private Sub Form_Click()
Dim j As Double, sum As Double, n As Integer, k as integer
j = 1
n = 1
k = 1
Do While n <= 10
j = j * n
sum = sum + j * k
k = - k
n = n + 1
Loop
Print sum
End Sub
相似回答