VB (Program Menghitung Kombinasi)

Public Class Form1
Dim P As Integer
Sub Bersih()
TxtN.Text = " "
TxtR.Text = " "
LblHasil.Text = " "
TxtN.Focus()

End Sub

Function faktorial(ByVal A As Integer) As Long
Dim f As Long
Dim i As Integer
f = 1
For i = 2 To A
f = f * i

Next
faktorial = f

End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Bersih()

End Sub

Private Sub BtnKosong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKosong.Click
Call Bersih()

End Sub

Private Sub BtnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHitung.Click
P = faktorial(TxtN.Text) / (faktorial(TxtN.Text - TxtR.Text) * faktorial(TxtR.Text))
End Sub
End Class

Category: 0 komentar

Tidak ada komentar:

Posting Komentar