VB:在不同的窗体上分别计算:y=(5!+7!)/8!和s=1!+2!+...+10!的值.要求在标准模块中定义求阶乘的函数过程
问题描述:
VB:在不同的窗体上分别计算:y=(5!+7!)/8!和s=1!+2!+...+10!的值.要求在标准模块中定义求阶乘的函数过程
答
form1上:
Private Sub Form_Click()
f = 1
For i = 1 To 8
f = f * i
If i = 5 Then a = f
If i = 7 Then b = f
Next i
y = (a + b) / f
Print "y=(5!+7!)/8!=" & y
End Sub
form2上:
Private Sub Form_Click()
f = 1
For i = 1 To 10
For j = 1 To i
f = f * j
Next j
s = s + f
Next i
Print "s=1!+2!+……+10!=" & s
End Sub