Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Integer = Val(TextBox1.Text)
        Dim S As Long = 1
        Dim i
        For i = 1 To a
            S = S * i
        Next
        TextBox2.Text = S
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim a As Integer = Val(TextBox1.Text)
        Dim S As Long = 1
        Dim i = 1

        While (i <= a)
            S *= i
            i += 1
        End While

        TextBox2.Text = S

    End Sub
End Class
