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
Netcode
Veteran Poster
1,037 posts since Jun 2009
Reputation Points: 43
Solved Threads: 70
Skill Endorsements: 0
Well, you've got your factorial code already supplied in this answer. Thats the hard part done, now all you have to do is build the interface. What part are you having trouble with?
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
Develop an application which reads two integers n1 and n2 from the user via two text-boxes and displays in a label the sum of the factorial of the integers n1 n2
You already have an answer from your own question. You made mention of having two text-boxes to take values, so from there you should know you need two text-boxes on your interface. To add to it, you would need a button which you would write the factorial codes behind it so when clicked, it does the factorial.
Netcode
Veteran Poster
1,037 posts since Jun 2009
Reputation Points: 43
Solved Threads: 70
Skill Endorsements: 0