I am trying to write code for a program in Visual Studo usingVisual Basic programming language that computes the factorial of anentered number by using a For Loop. My problem is that it keepsre-setting the variable for Factorial. Below is my code if anyonecan help. I want it to multiply the given number by that number -1, then continuing to do so until it hits zero without multiplyingby zero.
Private Sub BtnCalculate_Click(sender As Object, e As EventArgs)Handles btnCalculate.Click
Dim Factorial As Integer = Integer.Parse(txtNumber.Text)
For i = Factorial To 2 Step -1
Factorial = i * (i - 1)
Next
txtFactorial.Text = Factorial.ToString()
End Sub