Public Class Form3
Private Sub Form3_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 P As Long
P = expoment(TextBox1.Text)
Label2.Text = P
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
Label2.Text = ""
Button1.Enabled = True
Button2.Enabled = False
End Sub
End Class
Module Module1
Function expoment(ByVal txt_a As String) As Long
Dim k As Byte
Dim f As Long
k = CInt(txt_a)
f = 1
While (k > 1)
f = f * k
k = k - 1
End While
Return f
End Function
End Module
Top |