4 Replies - 4205 Views - Last Post: 08 January 2010 - 05:49 PM

#1 firebolt   User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Factorial Function

Posted 26 April 2009 - 11:25 PM

Description: An easier way to find the factorial of a number. Just place in the form and start.
Public Function Factorial(ByVal Factor As Byte) As Variant

If Factor = 0 Then
Factorial = 1
Else
Factorial = Factor * Factorial(Factor - 1)
End If

Exit Function


Private Sub Form_Load()

Dim x As Single
x = InputBox("Number")
MsgBox Factorial(x)

End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Factorial Function

#2 firebolt   User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Factorial Function

Posted 26 April 2009 - 11:25 PM

Description: An easier way to find the factorial of a number. Just place in the form and start.
Public Function Factorial(ByVal Factor As Byte) As Variant

If Factor = 0 Then
Factorial = 1
Else
Factorial = Factor * Factorial(Factor - 1)
End If

End Function


Private Sub Form_Load()

Dim x As Single
x = InputBox("Number")
MsgBox Factorial(x)

End Sub



Was This Post Helpful? 0
  • +
  • -

#3 iwantthependrive   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-February 09

Re: Factorial Function

Posted 03 May 2009 - 01:41 AM

You have not written "End Function". It should be after "Exit Function". it is giving an error otherwise.
Was This Post Helpful? 0
  • +
  • -

#4 firebolt   User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Factorial Function

Posted 03 May 2009 - 01:53 AM

Well Spotted. Wonder why whoever accepted it, didnt spot the error. Thanks but I dont think I can edit it now.
Was This Post Helpful? 0
  • +
  • -

#5 boka3090   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 08-January 10

Re: Factorial Function

Posted 08 January 2010 - 10:08 AM

thank but not explain in the program.please when write program one by one line ,explain by the comment. thanks
Was This Post Helpful? 0
  • +
  • -

#6 firebolt   User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Factorial Function

Posted 08 January 2010 - 05:49 PM

Its a snippet, not a tutorial.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1