Public Class Form1 Private Sub Button1_Click(ByVal sender As

Anuncio
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim fact As Long
Dim num As Integer
Dim i As Integer
'Inicializamos nuestras variables
num = TextBox1.Text
fact = 1
' Recordemos que el factorial de 0 es igual a 1, por lo cual
usaremos un "IF" para este caso
If num = 0 Then
TextBox1.Text = 1
'Si nuestro caso no es el anterior, lo calculamos con lo
siguiente
Else
For i = 1 To num
fact = fact * i
Next i
End If
TextBox2.Text = fact
End Sub
End Class
Descargar