有一个程序请求指点一下
编写程序计算1!+2!+3!+4!+5!+6!要求用sub过程和function过程分别编程。
请求有人快速指点一下。
Private Sub Command1_Click() Dim i As Long i = Val(Text1.Text) MsgBox AAA(i) Text1.Text = "" End Sub Private Function AAA(i As Long) As Long Dim j As Long, k As Long, Total As Long Total = 0 Do While i > 0 k = 1 For j = i To 1 Step -1 k = k * j Next j Total = Total + k i = i - 1 Loop AAA = Total End Function
Private Sub Command1_Click() Dim i As Long, j As Long, k As Long i = Val(Text1.Text) MsgBox AAA(i) Text1.Text = "" End Sub Private Function AAA(i As Long) As Long Dim j As Long, k As Long Do While i > 0 k = 1 For j = i To 1 Step -1 k = k * j Next j AAA = AAA + k i = i - 1 Loop End Function