在n个运动员中选出任意r个人参加比赛,有很多种不同的选法,选法的个数可以用公式计算。下图窗体中3个文本框的名称依次是Text1、Text2、Text。程序运行时在 Text1、Text2中分别输入n和r的值,单击Command1按钮即可求出选法的个数,并显示在
Text3文本框中(见下图)。请填空。
Private Sub Command1_Click()
Dim r As Integer,n As Integer
n=Textl
r=Text2
Text3=fun(n)/fun( 【1】 )/fun(r)
End Sub
Function fun(n As Integer)As Long
Dim t As Long
【2】
For k=1 To n
t-t*k
Next
fun=t
End Function