Option Explicit
Private Sub cmdCalc_Click()
Dim n As Integer, p As Integer
n = Abs(Val(txtN.Text))
p = Abs(Val(txtP.Text))
If n >
0 And p > 0 And n >= p Then
txtComb.Text = fact(n) / fact(n - p) / fact(p)
Else
txtComb.Text = ""
MsgBox "Erro: dados inválidos!", vbOKOnly
End If
End Sub
Private Sub cmdSair_Click()
End
End Sub
Function fact(n As Integer) As Double
Dim x As
Integer, f As Double
f = 1
For x = 2
To n
f = f
* x
Next
fact = f
End Function