Visual Basic > Code Snippets
Factorial function
Factorial function Public Function Factorial(ByVal Factor As Byte) As Variant On Error GoTo ErrorHandler If Factor = 0 Then Factorial = 1 Else Factorial = Factor * Factorial(Factor - 1) End If Exit Function ErrorHandler: MsgBox Err.Description End Function Private Sub Form_Load() MsgBox Factorial(3) End Sub
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows