Blog komunitas TI gaul

Mainkan Label dengan Berbagai Animasi

Posted on: December 15, 2008

we

Label biasanya untuk menampilkan kata/kalimat yg sifatnya diam (silent), tetapi apakah anda pernah membayangkan bahwa label bisa dimanfaatkan untuk melakukan berbagai macam animasi huruf/kata/kalimat? Jika ingin melihat dan mengetahui tips dan triknya silahkan simak kode VB berikut —>

-----------------------------------------------------
Objek           Nama     Properti         Value
-----------------------------------------------------
 Form           Form1    StartUpPosition  2-CenterScreen
                         ControlBox       False
                         Width            7000
                         Height           2500

 TextBox        Text1    Width            6600

 Label1         Label1   Width            6600
                         Alignment        2-Center
 CommandButton  Command1 -                -
 CommandButton  Command2 -                -
----------------------------------------------------

Letakkan kode berikut di Form:
-----------------------------

Option Explicit

Dim Play As Boolean
Sub Sleep(Delay%)
Dim Mulai%

  While Mulai < Delay - (1000) And Play = True
    Mulai = Mulai + 1
    DoEvents
  Wend
End Sub

Sub Damn()
Dim h$, f$, c$, I%, t%, d%
Dim strTemp$, length%
Dim buffLeft$, buffRight$

  If Play = False Then Exit Sub
  h = Text1

  '// Gaya Huruf Besar dan kecil
  Label1 = LCase(h)
  c = Label1
  For I = 1 To Len(h)
    Sleep 4000
    Mid(c, I, 1) = UCase(Mid(c, I, 1))
    Label1 = c
  Next I

  For I = 1 To Len(h)
    Sleep 4000
    Mid(c, (Len(h) + 1) - I, 1) = _
      LCase(Mid(c, (Len(h) + 1) - I, 1))
    Label1 = c
  Next I

  '// Gaya mengetik
  Label1 = "|"
  For I = 1 To 5
    Sleep 6000
    If Label1 = "|" Then
      Label1 = " "
    Else
      Label1 = "|"
    End If
  Next I

  For I = 1 To Len(h)
    Sleep 5000
    Label1 = Left(h, I) & "|"
  Next I
  
  Label1 = Left(Label1, Len(Label1) - 1)

  '// Berjalan dari sebelah kiri
  Label1 = h
  Do
    Sleep 5000
    Label1 = Mid(Label1, 2, Len(Label1) - 1) & Left(Label1, 1)
    DoEvents
  Loop Until Label1 = h

  '// Berjalan dari sebelah kanan
  Label1 = h
  Do
    Sleep 5000
    Label1 = Right(Label1, 1) & Left(Label1, Len(Label1) - 1)
  Loop Until Label1 = h

  '// Gaya Terbang
  t = Label1.Top
  Label1.Top = t + 500
  While Label1.Top >= t
    Sleep 500
    Label1.Top = Label1.Top - 10
  Wend
  Sleep 6000
  
  '// Gaya Menghilang
  Label1.Visible = False
  Sleep 15000
  Label1.Visible = True
  Sleep 17000
  
  '// Gaya ZOOM
  'Label1.Alignment = vbCenter
  For I = 1 To Label1.FontSize
    Sleep 5000
    Label1.FontSize = I
  Next I
  
  '// Gaya Strip
  Label1 = String(Len(h), " ")
  f = Label1
  For I = 1 To Len(h)
    Sleep 2500
    c = Mid(h, Len(h) - (I - 1), 1)
    Mid(f, Len(f) - (I - 1), 1) = c
    Label1 = f
  Next I
  
  '// Gaya Blink
  For I = 1 To 10
    Sleep 8000
    If Label1.Visible = True Then
    Label1.Visible = False
  Else
    Label1.Visible = True
    End If
  Next I
  
  '// Gaya Melompat dan Box
  strTemp = Label1
  For I = 1 To 2
    length = 0
    While length < Len(strTemp)
      Sleep 5000
      length = length + 1
      If I = 1 Then
        Label1 = String(Len(strTemp), " ")
        buffLeft = Label1
        Mid(buffLeft, length, 1) = Mid(strTemp, length, 1)
        Label1 = buffLeft
        buffRight = Label1
        Mid(buffRight, Len(strTemp) - (length - 1), 1) = _
          Mid(strTemp, Len(strTemp) - (length - 1), 1)
        Label1 = buffRight
      Else
        buffLeft = Label1
        Mid(buffLeft, length, length) = _
          Mid(strTemp, length, length)
        Label1 = buffLeft
        buffRight = Label1
        Mid(buffRight, Len(strTemp) - (length - 1), length) = _
          Mid(strTemp, Len(strTemp) - (length - 1), length)
        Label1 = buffRight
      End If
      DoEvents
    Wend
  Next I

  Damn
End Sub
  
Private Sub Command1_Click()
  If Command1.Caption = "Mulai" Then
    Command1.Caption = "Stop"
    Text1 = Text1 & " "
    Label1 = Text1
    Play = True
  Else
    Command1.Caption = "Mulai"
    Play = False
  End If
  Damn
End Sub

Private Sub Command2_Click()
  End
End Sub

Private Sub Form_Load()
  Form1.Caption = "Mainkan Label dengan Berbagai Animasi"
  Text1.Text = "Mainkan Label dengan Berbagai Animasi. Author: BEGO - CyberBoy."
  Command1.Caption = "Mulai"
  Command2.Caption = "Close"
End Sub
Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: