Hola, mira es muy sencillo. Aquí tienes una función que devuelve el factorial de un número mediante un bucle Do While.. Loop
Código:
Private Function Factorial(ByVal iNum As Integer) As Double
Dim i As Integer
i = 1
Factorial = 1
Do While i <= iNum
Factorial = Factorial * i
i = i + 1
Loop
End Function
Para probarlo, pon en un Form un TextBox (Text1) y un CommandButton (Command1), escribe un número en el TextBox y a continuación pincha en el Command.
Código:
Private Sub Command1_Click()
Dim n As Double
n = Factorial(Val(Text1))
MsgBox n
End Sub