'----------------------------------------------
'COMMAND1 FORMUN ALT TARAFINDA
'COMMAND2 FORMUN ÜST TARAFINDA
'SHAPE COMMAND2'NİN AZ ALTINDA
'COMMAND3 FORMUN ORTASINDA VİSİBLE ÖZELLİĞİ FALSE OLACAK.
'TİMER2.İNTERVAL=1
'TİMER1.İNTERVAL=1
2 TANE DE LABEL EKLEYELİM.
'----------------------------------------------
Private Sub Command3_Click()
Shape1.Left = 4200
Shape1.Top = 600
Timer1.Enabled = True
Command3.Visible = False
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyK Then Command1.Left = Command1.Left - 150
If Command1.Left + Command1.Width < 0 Then Command1.Left = 8520
If Command1.Left > 8520 Then Command1.Left = 0
If KeyCode = vbKeyL Then
Command1.Left = Command1.Left + 150
End If
If KeyCode = vbKeyQ Then Command1.Left = Command1.Left - 150
If Command1.Left + Command1.Width < 0 Then Command1.Left = 8520
If Command1.Left > 8520 Then Command1.Left = 0
If KeyCode = vbKeyW Then
Command1.Left = Command1.Left + 150
End If
If KeyCode = vbKeyP Then
Timer1.Enabled = Not (Timer1.Enabled)
End If
End Sub
Private Sub Timer1_Timer()
Static xa, ya
If IsEmpty(xa) Then xa = 33: ya = 33
'sol kenara gelince geri dön
If Shape1.Left <= 0 Then xa = -xa
'sağa kenara gelince geri dön
If Shape1.Left + Shape1.Width >= ScaleWidth Then xa = -xa
'üste kenara gelince geri dön
If (Shape1.Top >= Command2.Top) And (Shape1.Top < (Command2.Top + Command2.Height)) And (Shape1.Left > Command2.Left) And (Shape1.Left < (Command2.Left + Command2.Width)) Then ya = -ya: Beep
'command ile carpıştıgında geri dön
If (Shape1.Top + Shape1.Height >= Command1.Top) And (Shape1.Top < (Command1.Top + Command1.Height)) And (Shape1.Left > Command1.Left) And (Shape1.Left < (Command1.Left + Command1.Width)) Then ya = -ya: Beep
Shape1.Left = Shape1.Left + xa
Shape1.Top = Shape1.Top + ya
If Shape1.Top = 0 Then
MsgBox "BİTTİ", vbInformation + vbOKOnly, "SAYI"
Timer1.Enabled = False
Command3.Visible = True
Label1.Caption = Label1.Caption + 1
End If
If Shape1.Top >= ScaleHeight Then
MsgBox "BİTTİ", vbInformation + vbOKOnly, "SAYI"
Timer1.Enabled = False
Command3.Visible = True
Label2.Caption = Label2.Caption + 1
End If
End Sub
Private Sub Timer2_Timer()
Command2.Left = Shape1.Left - Command2.Width / 2
End Sub
'COMMAND1 FORMUN ALT TARAFINDA
'COMMAND2 FORMUN ÜST TARAFINDA
'SHAPE COMMAND2'NİN AZ ALTINDA
'COMMAND3 FORMUN ORTASINDA VİSİBLE ÖZELLİĞİ FALSE OLACAK.
'TİMER2.İNTERVAL=1
'TİMER1.İNTERVAL=1
2 TANE DE LABEL EKLEYELİM.
'----------------------------------------------
Private Sub Command3_Click()
Shape1.Left = 4200
Shape1.Top = 600
Timer1.Enabled = True
Command3.Visible = False
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyK Then Command1.Left = Command1.Left - 150
If Command1.Left + Command1.Width < 0 Then Command1.Left = 8520
If Command1.Left > 8520 Then Command1.Left = 0
If KeyCode = vbKeyL Then
Command1.Left = Command1.Left + 150
End If
If KeyCode = vbKeyQ Then Command1.Left = Command1.Left - 150
If Command1.Left + Command1.Width < 0 Then Command1.Left = 8520
If Command1.Left > 8520 Then Command1.Left = 0
If KeyCode = vbKeyW Then
Command1.Left = Command1.Left + 150
End If
If KeyCode = vbKeyP Then
Timer1.Enabled = Not (Timer1.Enabled)
End If
End Sub
Private Sub Timer1_Timer()
Static xa, ya
If IsEmpty(xa) Then xa = 33: ya = 33
'sol kenara gelince geri dön
If Shape1.Left <= 0 Then xa = -xa
'sağa kenara gelince geri dön
If Shape1.Left + Shape1.Width >= ScaleWidth Then xa = -xa
'üste kenara gelince geri dön
If (Shape1.Top >= Command2.Top) And (Shape1.Top < (Command2.Top + Command2.Height)) And (Shape1.Left > Command2.Left) And (Shape1.Left < (Command2.Left + Command2.Width)) Then ya = -ya: Beep
'command ile carpıştıgında geri dön
If (Shape1.Top + Shape1.Height >= Command1.Top) And (Shape1.Top < (Command1.Top + Command1.Height)) And (Shape1.Left > Command1.Left) And (Shape1.Left < (Command1.Left + Command1.Width)) Then ya = -ya: Beep
Shape1.Left = Shape1.Left + xa
Shape1.Top = Shape1.Top + ya
If Shape1.Top = 0 Then
MsgBox "BİTTİ", vbInformation + vbOKOnly, "SAYI"
Timer1.Enabled = False
Command3.Visible = True
Label1.Caption = Label1.Caption + 1
End If
If Shape1.Top >= ScaleHeight Then
MsgBox "BİTTİ", vbInformation + vbOKOnly, "SAYI"
Timer1.Enabled = False
Command3.Visible = True
Label2.Caption = Label2.Caption + 1
End If
End Sub
Private Sub Timer2_Timer()
Command2.Left = Shape1.Left - Command2.Width / 2
End Sub
Son düzenleme: