2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Jx_Man
2

try this :

Public Function Factorial(ByVal Number As Integer) As String
        Try
            If Number = 0 Then
                Return 1
            Else
                Return Number * Factorial(Number - 1)
            End If
        Catch ex As Exception
            Return ex.Message
        End Try
    End Function

I called this function in button click event:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       Dim num As Integer
        num = Val(InputBox("Enter the Factorial Number"))
        MsgBox(Factorial(num))
End Sub
Votes + Comments
thank you very much for your help
Well great
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.