Search Tools Links Login

Caption Animation - Timer Control


Visual Basic 6, or VB Classic

Beginner level discussion on proper use of the Timer Control. Give your About Box a bit of sex appeal.

Original Author: Ross Ylitalo

Code

Private m_strFullCaption As String
Private m_strCurrentCaption As String
Private m_ynLeftRight As Boolean
Private Sub Form_Load()
  m_strFullCaption = Me.Caption ' Don't mutate m_strFullCaption after this!
  Me.Caption = ""
  m_strCurrentCaption = ""
  m_ynLeftRight = True
End Sub
Private Sub tmr_Timer()
  If m_ynLeftRight Then
    ' Show caption from left to right.
    If Len(m_strCurrentCaption) < Len(m_strFullCaption) Then
      m_strCurrentCaption = Left(m_strFullCaption, Len(m_strCurrentCaption) + 1)
      Me.Caption = m_strCurrentCaption
    Else
      m_ynLeftRight = Not m_ynLeftRight
    End If
  Else
    ' Scroll caption off of screen, scrolling Left.
    If Len(m_strCurrentCaption) > 0 Then
      m_strCurrentCaption = Right(m_strFullCaption, Len(m_strCurrentCaption) - 1)
      Me.Caption = m_strCurrentCaption
    Else
      m_ynLeftRight = Not m_ynLeftRight
    End If
  End If
End Sub

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 112 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.