Private Sub cmdfac_Click()
Text2.Text = fact(Val(Text1.Text))
End Sub

Public Function fact(number As Integer)
f = 1
For i = number To 1 Step -1
f = f * i
Next
fact = f
End Function