Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, res As Integer
a = CInt(TextBox1.Text)
res = fact(a)
Label1.Text = res.ToString
End Sub
Function fact(ByVal x As Integer) As Integer
Dim count, result As Integer
count = 1
result = 1
While count <= x
result = result * count
count = count + 1
End While
Return result
End Function
End Class