Design:
Code:
Public Class Form1
Dim fact As Integer = 0
Dim num, f As Integer
Function Factorial(ByVal num As Integer)
If num = 1 Then
Return 1
Else
f = Factorial(num - 1) * num
Return f
End If
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
num = TextBox1.Text
f = Factorial(num)
Label2.Text = f
End Sub
End Class
Code:
Public Class Form1
Dim fact As Integer = 0
Dim num, f As Integer
Function Factorial(ByVal num As Integer)
If num = 1 Then
Return 1
Else
f = Factorial(num - 1) * num
Return f
End If
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
num = TextBox1.Text
f = Factorial(num)
Label2.Text = f
End Sub
End Class