VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Factorial calculates the Factorial of a number recursively using Visual Basic 6. The Factorial of a

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

Rate Factorial calculates the Factorial of a number recursively using Visual Basic 6. The Factorial of a



  <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 .&nbsp;</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>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#00FF00">'The Factorial of 0 is equal to 1</font><font color="#000080"><br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Result = 1<br>
                  <br>
                  Case Else<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#00FF00">'Recursively call the Factorial Function</font><font color="#000080"><br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>
                  &nbsp;&nbsp;&nbsp;&nbsp; MsgBox "An Error Has Occured! Contact
                  <a href="http://www.visual-basic-data-mining.net">http://www.visual-basic-data-mining.net</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  with this information : " &amp; _ "Error Number : " &amp; Err.number &amp; ", Error
                  Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : " &amp; Err.Description, vbCritical, "MathSDK.Factorial"<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>


Download this snippet    Add to My Saved Code

Factorial calculates the Factorial of a number recursively using Visual Basic 6. The Factorial of a Comments

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.

Post your comment

Subject:
Message:
0/1000 characters