Factorial calculator in windows Application

Posted by Chikul under Windows Forms category on | Views : 4252
'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

Comments or Responses

Login to post response