Public Class Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
TextBox1.Text = 5
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n, f, k As Integer
n = Val(TextBox1.Text)
f = 1
k = n
While (k > 1)
f = f * k
k = k - 1
End While
ListBox1.Items.Add(TextBox1.Text & " ! " & " = " & f)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
ListBox1.Items.Clear()
Button1.Enabled = True
End Sub
End Class |