by http://www.visual-basic-data-mining.net (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 11th August 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Factorial calculates the Factorial of a number recursively using Visual Basic 6. The Factorial of a number X! is given by the product of X and
<table border="1" cellspacing="5" width="800">
<tr>
<td>
<table border="0" cellspacing="5" width="800">
<tr>
<td><font face="Verdana" size="1">Data Mining Libraries and
Classes created and documented by <a href="http://www.visual-basic-data-mining.net/webpages/SiteIndex.aspx">http://www.visual-basic-data-mining.net/webpages/SiteIndex.aspx</a>
, <a href="http://www.visual-basic-data-mining.com">http://www.visual-basic-data-mining.com</a></font>
<p><font face="Verdana" size="3" color="#000080"><b>Factorial
calculates the Factorial of a number recursively using Visual
Basic 6. The Factorial of a number X! is given by the product of
X and (X-1)! where 3! = 3 * 2 * 1 . </b></font>
<p></td>
</tr>
<tr>
<td><font face="Verdana" size="3"><br>
<b>Public Function Factorial(number As Long) As Double</b><br>
On Error GoTo ErrorHandler</font></td>
</tr>
<tr>
<td>
<blockquote>
<p><font face="Verdana" size="3"><font color="#00FF00"><b>'Factorial of X is X! and X! = X * (X-1)!<br>
'E.g. 3! = 3 * 2!<br>
'For completeness, 3! = 3 * 2 * 1</b></font><br>
<br>
Dim Result As Double</font></p>
</blockquote>
</td>
</tr>
<tr>
<td>
<blockquote>
<p><font face="Verdana" size="3"><b><font color="#000080">Select Case number<br>
<br>
Case 0<br>
</font><font color="#00FF00">'The Factorial of 0 is equal to 1</font><font color="#000080"><br>
Result = 1<br>
<br>
Case Else<br>
</font><font color="#00FF00">'Recursively call the Factorial Function</font><font color="#000080"><br>
Result = (number * Factorial(number - 1))<br>
<br>
End Select<br>
<br>
<br>
Factorial = Result</font></b><br>
<br>
<br>
Exit_ErrorHandler:<br>
Exit Function<br>
<br>
<br>
ErrorHandler:<br>
MsgBox "An Error Has Occured! Contact
<a href="http://www.visual-basic-data-mining.net">http://www.visual-basic-data-mining.net</a>
with this information : " & _ "Error Number : " & Err.number & ", Error
Description : " & Err.Description, vbCritical, "MathSDK.Factorial"<br>
<br>
Resume Exit_ErrorHandler</font></p>
</blockquote>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><font face="Verdana" size="3"><b>End Function</b></font></td>
</tr>
</table>
</div>
No comments have been posted about Factorial calculates the Factorial of a number recursively using Visual Basic 6. The Factorial of a. Why not be the first to post a comment about Factorial calculates the Factorial of a number recursively using Visual Basic 6. The Factorial of a.