Tutorial kali ini membuat animasi label bergerak, berkedip dengan menggunakan fungsi dan komponen Timer.

1. Buatlah desain Form seperti berikut ini

Nama Control Properties Nilai
RadioButton1 Text Berkedip
RadioButton2 Text Berjalan Kanan Ke Kiri
RadioButton3 Text Berjalan Bawah Ke Atas
Label1 Text Deddy Rusdiansyah
Timer1 Enabled True

Ketikan Kode Program dibawah ini :

Imports VB = Microsoft.VisualBasic
Public Class Form1
Dim Animasi, MA, XI, KOM As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Animasi = “Deddy Rusdiansyah”
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.RadioButton1.Checked = True Then
Timer1.Interval = 250
Me.Label1.Visible = Not Me.Label1.Visible
ElseIf Me.RadioButton2.Checked = True Then
Timer1.Interval = 100
Label1.Visible = True
On Error Resume Next
MA = VB.Left(Animasi, 1)
XI = VB.Len(Animasi)
KOM = VB.Right(Animasi, XI – 1)
Animasi = KOM + MA
Me.Label1.Text = Animasi
ElseIf Me.RadioButton3.Checked = True Then
Timer1.Interval = 100
Label1.Visible = True
If Label1.Top < Me.Height – Me.Height – Label1.Height Then
Label1.Top = Me.Height – 1
Label1.Top = Label1.Top – 25
Else
Label1.Top = Label1.Top – 25
End If
End If
End Sub
End Class

Run [F5]

Hasilnya :