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


Top 5 Contributors of the Month
david stephan

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
        Try
            intNumber = Val(txtNumber.Text.Trim)
            IntFactorial = fnGetFactorial(intNumber)
            lblresult.Text = IntFactorial
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        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
        Next
        fnGetFactorial = intfac
    End Function

End Class

     

Further Readings:

Responses

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