这个题的代码怎么写(VB) 急!!

来源:百度知道 编辑:UC知道 时间:2024/06/20 20:45:28
求s=A!+B!+C!,阶乘的计算用sub和function过程来实现
好像没办法运行,能不能具体点儿

Private Sub Command1_Click()
s=jc(5)+jc(4)+jc(3)
End Sub
Private Function jc(ByVal num As Single) As Single
Dim sum As Single
sum = 1
Do While Not num = 1
sum = sum * num
num = num - 1
Loop
jc = sum
End Function

Sub abc()
A = 5
B = 4
C = 3
S = jiechen(A) + jiechen(B) + jiechen(C)

End Sub

Function jiechen(x)
If x = 1 Then
jiechen = 1
Else: jiechen = jiechen(x - 1) * x
End If
End Function