Public Class Hitung_Faktorial
Dim nilai As Long
Dim faktorial As Long
Private Sub BtnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHitung.Click
nilai = TxtBilangan.text
If nilai <= 0 Or nilai = 1 Then
LblFaktorial.Text = 1
ElseIf nilai > 1 Then
For Me.faktorial = nilai - 1 To 1 Step -1
nilai = nilai * faktorial
Next faktorial
LblFaktorial.Text = nilai
End If
End Sub
Private Sub BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapus.Click
TxtBilangan.Clear()
LblFaktorial.Text = ""
TxtBilangan.Focus()
End Sub
Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
Me.Close()
End Sub
End Class
Tidak ada komentar:
Posting Komentar
Berkomentarlah yang baik..