factorial function

Posted on March 9th, 2009 in Visual Basic by admin

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

Related posts:

  1. delete a folder Dim strDir As String Private Sub Command1_Click() On Error GoTo...
  2. get drive serial number Private Const MAX_FILENAME_LEN = 256 Private Declare Function GetVolumeInformation& Lib...
  3. circular form Private Declare Function CreateEllipticRgn Lib “gdi32″ (ByVal X1 As Long,...
  4. Get drive volume information Private Declare Function GetVolumeInformation Lib “kernel32″ Alias “GetVolumeInformationA” (ByVal lpRootPathName...
  5. check whether you can play audio files Private Declare Function waveOutGetNumDevs Lib “winmm.dll” () As Long Private...

Related posts brought to you by Yet Another Related Posts Plugin.

Post a comment