在命令按钮Command1的单击事件中计算m!/(n!*(m-n)!)的值,并在标签Label4中输出;当输入的m小于n时,直接在标签Label4中输出:"error" (不包括引号)其中m、n依次分别由文本框Text1和Text2输入。要求使用函数过程Factorial(n)实现计算n!。说明:1)不要更改函数名Factorial2)函数参数n为整型【我做的】Function factorial(n As Integer) As DoubleDim i As Integer, T As DoubleT = 1For i = 1 To nT = T * iNext ifactorial = TEnd FunctionPrivate Sub Command1_Click()Dim m As Integer, n As Integerm = Val(Text1.Text): n = Val(Text2.Text)If m < n ThenLabel4.Caption = "error"Exit SubEnd IfLabel4.Caption = factorial(m) / (factorial(n) * factorial(m - n))End Sub
- 2 回答
- 0 关注
- 64 浏览
添加回答
举报
0/150
提交
取消