【实验要求】
已知sum=1!-2!+3!-4!~10!,鼠标单击窗体,请将sum结果值输出到窗体上(要求:使用do whilel~loop语句完成程序)。
~为什么这么写显示堆栈溢出啊
Dim p As Integer 'p变量存放阶乘的值
Dim sum As Long
p = 1
Do While p <= 10
sum = sum + jc(p) * (-1) ^ (p - 1)
p = p + 1
Loop
Print sum
End Sub
Private Function jc(ByVal n As Long) As Long '阶乘
If p = 1 Then
jc = 1
Else
jc = p * jc(p - 1)
End If
End Function
~怎么写才能做成功啊
Private Sub Form_Click()
Dim p As Long 'p变量存放阶乘的值
Dim sum As Long
End
End Sub