RSS

Animasi Form Di VB6


:


Di bawah ini bisa di lihat Source Programnya 









Private Sub Form_Load()
Me.Height = 10
End Sub
Private Sub Timer1_Timer()
Me.Height = Me.Height + 100
Tengah
If Me.Height >= 3000 Then
Timer1.Enabled = False
Tengah
End If
End Sub

Public Sub Tengah()
Me.Left = (Screen.Width – Me.Width) / 2
Me.Top = (Screen.Height – Me.Height) / 2
End Sub
Form muncul melebar:
Private Sub Form_Load()
Me.Width = 10
End Sub
Private Sub Timer1_Timer()
Me.Width = Me.Width + 100
Tengah
If Me.Width >= 4000 Then
Timer1.Enabled = False
Tengah
End If
End Sub
Public Sub Tengah()
Me.Left = (Screen.Width – Me.Width) / 2
Me.Top = (Screen.Height – Me.Height) / 2
End Sub
Form Unload efek slideToRight
Private Sub Form_Unload(Cancel As Integer)
Do
Me.Left = Me.Left + 40
Me.Move Me.Left, Me.Top
DoEvents
Loop Until Me.Left > Screen.Width
End Sub
Form Unload efek slideDown
Private Sub Form_Unload(Cancel As Integer)
Do
Me.Top = Me.Top + 40
Me.Move Me.Left, Me.Top
DoEvents
Loop Until Me.Top > Screen.Height – 500
End Sub


Program Tambahan Visual Basic Bagian 1 : Animasi Gerakan Form
Kita akan belajar membuat sebuah form mempunyai animasi ketika dibuka atau ditutup.
(Jika kurang mengerti silahkan lihat gambar paling bawah).
1. Buatlah 3 buah form baru disertai dengan objek objek lainnya seperti dibawah ini :

NAME
CAPTION
TOOL
Form1
ANIMASI
Form
Form2
VERTIKAL
Form
Form3
HORIZONTAL
Form
CmdBukaSamping
Buka Samping
CommandButton
CmdBukaAtas
Buka Atas
CommandButton
CmdTutupSamping
Tutup Samping
CommandButton
CmdTutupBawah
Tutup Bawah
CommandButton
Timer1 (FORM2)
-
Timer
Timer2 (FORM3)
-
Timer
 
2. Keterangan :
– CmdBukaSamping dan CmdBukaAtas diletakkan pada Form1
- CmdTutupSamping diletakkan pada FORM2
- CmdTutupBawah diletakkan pada FORM3
- Timer1 diletakan pada FORM2
- Timer2 diletakan pada FORM3
- Timer1 dan Timer2 intervalnya dirubah menjadi 1

3. Listing Programnya adalah :
- Form1 (ANIMASI)
Private Sub CMDBUKASAMPING_Click()
Form2.Show
End Sub
Private Sub CMDBUKAATAS_Click()
Form3.Show
End Sub

- Form2 (HORIZONTAL)
Private Sub CMDTUTUPSAMPING_Click()
Do
Me.Left = Me.Left + 40
Me.Move Me.Left, Me.Top
DoEvents
Loop Until Me.Left > Screen.Width
Unload Me
End Sub
Private Sub Form_Load()
Me.Width = 10
End Sub
Private Sub Timer1_Timer()
Me.Width = Me.Width + 100
Tengah
If Me.Width >= 4000 Then
Timer1.Enabled = False
Tengah
End If
End Sub
Public Sub Tengah()
Me.Left = (Screen.Width – Me.Width) / 2
Me.Top = (Screen.Height – Me.Height) / 2
End Sub



- Form3 (VERTIKAL)
Private Sub CMDTUTUPBAWAH_Click()
Do
Me.Top = Me.Top + 40
Me.Move Me.Left, Me.Top
DoEvents
Loop Until Me.Top > Screen.Height – 500
Unload Me
End Sub
Private Sub Form_Load()
Me.Height = 10
End Sub
Private Sub Timer2_Timer()
Me.Height = Me.Height + 100
Tengah
If Me.Height >= 3000 Then
Timer1.Enabled = False
Tengah
End If
End Sub
Public Sub Tengah()
Me.Left = (Screen.Width – Me.Width) / 2
Me.Top = (Screen.Height – Me.Height) / 2
End Sub



  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS