Dalam Pemrograman ini akan membuat sebuah Program, Program Mouse ke Button Maka Button Akan Berpindah Tempat.
Disini saya akan membuat sesuatu program yaitu :
Disini saya akan membuat sesuatu program yaitu :
- Kiri Ke Kanan
- Kanan Ke Kiri
- Atas Ke Bawah
- Bawah Ke Atas
Dan Jika Mouse di Gerakkan ke Button Maka Hasilnya seperti ini :
Dan ini Script Codenya :
Private Sub cmdAtas_Click()
If cmdAtas.Left = 1200 And cmdAtas.Top = 2400 Then
cmdAtas.Left = 1200
cmdAtas.Top = 5640
ElseIf cmdAtas.Left = 1200 And cmdAtas.Top = 5640 Then
cmdAtas.Left = 1200
cmdAtas.Top = 2400
End If
End Sub
Private Sub cmdAtas_KeyPress(KeyAscii As Integer)
cmdAtas.SetFocus
If KeyAscii = 13 Then
If cmdAtas.Left = 1200 And cmdAtas.Top = 2400 Then
cmdAtas.Left = 1200
cmdAtas.Top = 5640
cmdAtas.SetFocus
ElseIf cmdAtas.Left = 1200 And cmdAtas.Top = 5640 Then
cmdAtas.Left = 1200
cmdAtas.Top = 2400
cmdAtas.SetFocus
End If
End If
End Sub
Private Sub cmdAtas_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdAtas.Left = 1200 And cmdAtas.Top = 2400 Then
cmdAtas.Left = 1200
cmdAtas.Top = 5640
ElseIf cmdAtas.Left = 1200 And cmdAtas.Top = 5640 Then
cmdAtas.Left = 1200
cmdAtas.Top = 2400
End If
End Sub
Private Sub cmdBawah_Click()
If cmdBawah.Left = 3960 And cmdBawah.Top = 5640 Then
cmdBawah.Left = 3960
cmdBawah.Top = 2400
ElseIf cmdBawah.Left = 3960 And cmdBawah.Top = 2400 Then
cmdBawah.Left = 3960
cmdBawah.Top = 5640
End If
End Sub
Private Sub cmdBawah_KeyPress(KeyAscii As Integer)
cmdBawah.SetFocus
If KeyAscii = 13 Then
If cmdBawah.Left = 3960 And cmdBawah.Top = 5640 Then
cmdBawah.Left = 3960
cmdBawah.Top = 2400
cmdBawah.SetFocus
ElseIf cmdBawah.Left = 3960 And cmdBawah.Top = 2400 Then
cmdBawah.Left = 3940
cmdBawah.Top = 5640
cmdBawah.SetFocus
End If
End If
End Sub
Private Sub cmdBawah_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdBawah.Left = 3960 And cmdBawah.Top = 5640 Then
cmdBawah.Left = 3960
cmdBawah.Top = 2400
ElseIf cmdBawah.Left = 3960 And cmdBawah.Top = 2400 Then
cmdBawah.Left = 3960
cmdBawah.Top = 5640
End If
End Sub
Private Sub cmdKanan_Click()
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
ElseIf cmdKanan.Left = 240 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 5000
End If
End Sub
Private Sub cmdKanan_KeyPress(KeyAscii As Integer)
cmdKanan.SetFocus
If KeyAscii = 13 Then
If cmdKanan.Left = 5000 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 240
cmdKanan.SetFocus
ElseIf cmdKanan.Left = 240 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 5000
cmdKanan.SetFocus
End If
End If
End Sub
Private Sub cmdKanan_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdKanan.Left = 5000 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 240
cmdKanan.Top = 1200
ElseIf cmdKanan.Left = 240 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 5000
cmdKanan.Top = 1200
End If
End Sub
Private Sub cmdKiri_Click()
If cmdKiri.Left = 240 And cmdKiri.Top = 240 Then
cmdKiri.Left = 5000
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
End If
End Sub
Private Sub cmdKiri_KeyPress(KeyAscii As Integer)
cmdKiri.SetFocus
If KeyAscii = 13 Then
If cmdKiri.Left = 240 And cmdKiri.Top = 240 Then
cmdKiri.Left = 5000
cmdKiri.SetFocus
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
cmdKiri.SetFocus
End If
End Sub
Private Sub cmdKiri_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdKiri.Left = 240 And cmdKiri.Top = 240 Then
cmdKiri.Left = 5000
cmdKiri.Top = 240
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
cmdKiri.Top = 240
End If
End Sub
If cmdAtas.Left = 1200 And cmdAtas.Top = 2400 Then
cmdAtas.Left = 1200
cmdAtas.Top = 5640
ElseIf cmdAtas.Left = 1200 And cmdAtas.Top = 5640 Then
cmdAtas.Left = 1200
cmdAtas.Top = 2400
End If
End Sub
Private Sub cmdAtas_KeyPress(KeyAscii As Integer)
cmdAtas.SetFocus
If KeyAscii = 13 Then
If cmdAtas.Left = 1200 And cmdAtas.Top = 2400 Then
cmdAtas.Left = 1200
cmdAtas.Top = 5640
cmdAtas.SetFocus
ElseIf cmdAtas.Left = 1200 And cmdAtas.Top = 5640 Then
cmdAtas.Left = 1200
cmdAtas.Top = 2400
cmdAtas.SetFocus
End If
End If
End Sub
Private Sub cmdAtas_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdAtas.Left = 1200 And cmdAtas.Top = 2400 Then
cmdAtas.Left = 1200
cmdAtas.Top = 5640
ElseIf cmdAtas.Left = 1200 And cmdAtas.Top = 5640 Then
cmdAtas.Left = 1200
cmdAtas.Top = 2400
End If
End Sub
Private Sub cmdBawah_Click()
If cmdBawah.Left = 3960 And cmdBawah.Top = 5640 Then
cmdBawah.Left = 3960
cmdBawah.Top = 2400
ElseIf cmdBawah.Left = 3960 And cmdBawah.Top = 2400 Then
cmdBawah.Left = 3960
cmdBawah.Top = 5640
End If
End Sub
Private Sub cmdBawah_KeyPress(KeyAscii As Integer)
cmdBawah.SetFocus
If KeyAscii = 13 Then
If cmdBawah.Left = 3960 And cmdBawah.Top = 5640 Then
cmdBawah.Left = 3960
cmdBawah.Top = 2400
cmdBawah.SetFocus
ElseIf cmdBawah.Left = 3960 And cmdBawah.Top = 2400 Then
cmdBawah.Left = 3940
cmdBawah.Top = 5640
cmdBawah.SetFocus
End If
End If
End Sub
Private Sub cmdBawah_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdBawah.Left = 3960 And cmdBawah.Top = 5640 Then
cmdBawah.Left = 3960
cmdBawah.Top = 2400
ElseIf cmdBawah.Left = 3960 And cmdBawah.Top = 2400 Then
cmdBawah.Left = 3960
cmdBawah.Top = 5640
End If
End Sub
Private Sub cmdKanan_Click()
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
ElseIf cmdKanan.Left = 240 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 5000
End If
End Sub
Private Sub cmdKanan_KeyPress(KeyAscii As Integer)
cmdKanan.SetFocus
If KeyAscii = 13 Then
If cmdKanan.Left = 5000 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 240
cmdKanan.SetFocus
ElseIf cmdKanan.Left = 240 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 5000
cmdKanan.SetFocus
End If
End If
End Sub
Private Sub cmdKanan_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdKanan.Left = 5000 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 240
cmdKanan.Top = 1200
ElseIf cmdKanan.Left = 240 And cmdKanan.Top = 1200 Then
cmdKanan.Left = 5000
cmdKanan.Top = 1200
End If
End Sub
Private Sub cmdKiri_Click()
If cmdKiri.Left = 240 And cmdKiri.Top = 240 Then
cmdKiri.Left = 5000
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
End If
End Sub
Private Sub cmdKiri_KeyPress(KeyAscii As Integer)
cmdKiri.SetFocus
If KeyAscii = 13 Then
If cmdKiri.Left = 240 And cmdKiri.Top = 240 Then
cmdKiri.Left = 5000
cmdKiri.SetFocus
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
cmdKiri.SetFocus
End If
End Sub
Private Sub cmdKiri_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdKiri.Left = 240 And cmdKiri.Top = 240 Then
cmdKiri.Left = 5000
cmdKiri.Top = 240
ElseIf cmdKiri.Left = 5000 And cmdKiri.Top = 240 Then
cmdKiri.Left = 240
cmdKiri.Top = 240
End If
End Sub
NB : Selamat Mencoba.........
0 komentar:
Posting Komentar