在VB中,输入任意一个整数N,输出1!+2!+……+n!的累加和,请问怎么写代码
展开全部
Private Sub Command1_Click()
Dim n As Integer
Dim sum As Double
sum = 0
n = InputBox("请输入n的值")
For i = 1 To n
sum = sum + jiecheng(i)
Next i
Print sum
End Sub
Public Function jiecheng(ByVal n As Integer) As Double
Dim jc As Double
jc = 1
For i = 1 To n
jc = jc * i
Next
jiecheng = jc
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询