SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size

How to Create Animated Writing Text in Visual Basic 6 using Timer Control?

E-mail Print PDF

This article shows you Visual Basic 6 code to create sample running text (text written) animation using Timer Control. There are three types of direction of the running text: 1) From left to right 2) From right to left and 3) from the middle. Below is the sample in timer procedure block.

Private Sub trmText_Timer()
   If lblCaption.Caption <> StrCap Then
     If lblCaption.Alignment = 0 Then
        'run from left
        lblCaption.Caption = Left(StrCap, Len(lblCaption.Caption) + 1)
     ElseIf lblCaption.Alignment = 1 Then
        'run from right
        lblCaption.Caption = Right(StrCap, Len(lblCaption.Caption) + 1)
     ElseIf lblCaption.Alignment = 2 Then
        'run from the middle
       lblCaption.Caption = Mid(StrCap, Len(StrCap) \ 2 + Len(StrCap) Mod 2 - Num, _
                            2 * (Num + 1) - Len(StrCap) Mod 2)
       Num = Num + 1
     End If
   Else
      lblCaption.Caption = ""
      Num = 0
   End If
End Sub
This is a sample output of running text from Left to Right.

Download Source Code