Here's a very simple function for VB (written in VB6) to calculate the factorial (!) of a number. Note that it is limited by the magnitude of the value which can be stored in the Long data type. (In fact, I believe it overflows at 13!)
[CODE=vb]Public Function Factorial(ByVal bNum As Byte) As Long
Dim I As Long
If bNum <= 0 Then Exit Function
Factorial = 1
For I = 1 To bNum
Factorial = Factorial * I
Next
End Function[/CODE]
[CODE=vb]Public Function Factorial(ByVal bNum As Byte) As Long
Dim I As Long
If bNum <= 0 Then Exit Function
Factorial = 1
For I = 1 To bNum
Factorial = Factorial * I
Next
End Function[/CODE]