.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Factorial calculator in windows Application

Posted By:Prasanti Prusty       Posted Date: February 28, 2010    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

Factorial calculator in windows Application



'Factorial calculator in windows Application

Public Class frmFactorialCalculator

    Private Sub btnCalFactorial_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalFactorial.Click
        Dim intNumber As Integer = 0
        Dim IntFactorial As Integer = 0
            intNumber = Val(txtNumber.Text.Trim)
            IntFactorial = fnGetFactorial(intNumber)
            lblresult.Text = IntFactorial
        Catch ex As Exception
        End Try
    End Sub

    'Factorial Function Codes
    Private Function fnGetFactorial(ByVal num As Integer) As Integer
        Dim intfac As Integer = 1
        Dim i As Integer

        For i = 2 To num
            intfac *= i
        fnGetFactorial = intfac
    End Function

End Class


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend