Tuesday, September 27, 2011

Program Tebak Perkalian dengan Visual Basic

Option Explicit
Dim kali As Integer
Dim angkaprob As Integer, angkabetul As Integer

Private Sub command1_Click()
Dim angka1 As Integer
Dim angka2 As Integer
Text1.Text = ""
Label7.Caption = ""
angkaprob = angkaprob + 1
angka1 = Int(Rnd * 10) + 1
angka2 = Int(Rnd * 10) + 1
Label1.Caption = Format(angka1, "#0")
Label3.Caption = Format(angka2, "#0")
kali = angka1 * angka2
Command1.Enabled = False
Text1.SetFocus
End Sub

Private Sub command2_click()
Unload Me
End Sub

Private Sub Form_Activate()
Call command1_Click
End Sub

Private Sub Form_Load()
Randomize Timer
angkaprob = 0
angkabetul = 0
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim jawab As Integer
If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = vbKeyBack Then
Exit Sub
ElseIf KeyAscii = vbKeyReturn Then
jawab = Val(Text1.Text)
If jawab = kali Then
angkabetul = angkabetul + 1
Label7.Caption = "Jawaban Betul"
Else
Label7.Caption = "Yang Betul:" + Format(kali, "#0")
End If
Label6.Caption = Format(100 * angkabetul / angkaprob, "##0")
Command1.Enabled = True
Command1.SetFocus
Else
KeyAscii = 0
End If
End Sub

Categories:

0 comments:

Post a Comment

http://www.resepkuekeringku.com/2014/11/resep-donat-empuk-ala-dunkin-donut.html http://www.resepkuekeringku.com/2015/03/resep-kue-cubit-coklat-enak-dan-sederhana.html http://www.resepkuekeringku.com/2014/10/resep-donat-kentang-empuk-lembut-dan-enak.html http://www.resepkuekeringku.com/2014/07/resep-es-krim-goreng-coklat-kriuk-mudah-dan-sederhana-dengan-saus-strawberry.html http://www.resepkuekeringku.com/2014/06/resep-kue-es-krim-goreng-enak-dan-mudah.html http://www.resepkuekeringku.com/2014/09/resep-bolu-karamel-panggang-sarang-semut-lembut.html

Copyright © Catatan Anis Syarifah | Powered by Anis Syarifah