·
Buka
proyek Standard EXE yang baru
·
Disain
tampilan form seperti gambar berikut dengan menggunakan CommandButton dan objek
Timer sebanyak 4 buah.
Gbr 1
· Atur Properties masing - masing kontrol
seperti dibawah ini :
Kontrol
|
Properties
|
Pengaturan
|
Timer1
|
Name
Interval
|
tmr_atas
100
|
Timer2
|
Name
Interval
|
tmr_bawah
100
|
Timer3
|
Name
Interval
|
tmr_kanan
100
|
Timer4
|
Name
Interval
|
tmr_kiri
100
|
CommandButton1
|
Name
Caption
|
cmd_atas
Form Bergerak Ke Atas
|
CommandButton2
|
Name
Caption
|
cmd_bawah
Form Bergerak Ke Bawah
|
CommandButton3
|
Name
Caption
|
cmd_kanan
Form Bergerak Ke Kanan
|
CommandButton4
|
Name
Caption
|
cmd_kiri
Form Bergerak Ke Kiri
|
·
Klik
menu View => Code, lalu copy paste (copas) kode program di
bawah ini :
Private Sub cmd_atas_Click()Me.tmr_atas.Enabled = TrueEnd SubPrivate Sub cmd_bawah_Click()Me.tmr_bawah.Enabled = TrueEnd SubPrivate Sub cmd_kanan_Click()Me.tmr_kanan.Enabled = TrueEnd SubPrivate Sub cmd_kiri_Click()Me.tmr_kiri.Enabled = TrueEnd SubPrivate Sub Form_Load()Me.tmr_atas.Enabled = FalseMe.tmr_bawah.Enabled = FalseMe.tmr_kanan.Enabled = FalseMe.tmr_kiri.Enabled = FalseEnd SubPrivate Sub tmr_atas_Timer()DoEventsFor i = 1 To Form1.TopIf Form1.Top < Screen.Width ThenForm1.Top = Trim(Str(Int(Form1.Top) - 10))End IfNext iEndEnd SubPrivate Sub tmr_bawah_Timer()DoEventsFor i = 1 To Screen.WidthIf Form1.Top < Screen.Width ThenForm1.Top = Trim(Str(Int(Form1.Top) + 10))End IfNext iEndEnd SubPrivate Sub tmr_kanan_Timer()DoEventsFor i = 1 To Screen.WidthIf Form1.Left < (Screen.Height * 2) ThenForm1.Left = Trim(Str(Int(Form1.Left) + 10))End IfNext iEndEnd SubPrivate Sub tmr_kiri_Timer()DoEventsFor i = 1 To Form1.LeftIf Form1.Left < Screen.Height ThenForm1.Left = Trim(Str(Int(Form1.Left) - 10))End IfNext iEndEnd Sub
·
Jalankan
Program dengan cara menekan tombol F5 pada keyboard atau pilih menu Run => Start
Source Code
Tidak ada komentar:
Posting Komentar
Pos kan komentar anda !