Coding program mencari Faktorial :
Private Sub angka_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdfaktorial.SetFocus
End If
End Sub
Private Sub cmdend_Click()
End
End Sub
Private Sub cmdfaktorial_Click()
bil = 1
aa = Val(angka.Text) + 1
For i = 1 To Val(angka.Text)
bil = bil * i
aa = aa - 1
If i = 1 Then
txtfaktorial.Text = angka.Text
Else
txtfaktorial.Text = txtfaktorial.Text & " x " & Str(aa)
End If
Next
hasilfaktorial.Text = Str(bil)
txtfaktorial.Text = txtfaktorial.Text & " = " & Str(bil)
txtfaktorial.Enabled = False
hasilfaktorial.Enabled = False
End Sub
Private Sub cmdulang_Click()
angka.Text = ""
txtfaktorial.Text = ""
hasilfaktorial.Text = ""
angka.SetFocus
End Sub
Tidak ada komentar:
Posting Komentar