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
0 comments:
Post a Comment