Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleRotate text in a Caption
Keywordstext, rotate, Caption
CategoriesGraphics, Controls
 
Thanks to Sergio Perciballi.

This example uses a cRotateCaption class to represent text. The class contains a reference to the label or form where it should display itself as a Caption. The rotate method makes the class rotate its text 1 position and redisplay itself in the associated object's Caption property.

 
Sub rotate()
Dim str As String
Dim partMsg As String

    On Error GoTo err_handler
    ''counter for 1 to len(msg)
    If index = Len(m_msg) Then
        index = 1
    Else
        index = index + 1
    End If
    partMsg = Mid$(m_msg, index, m_Maxlen)
    'we have come to end of message and return less letters
    'str is the added, wrapped part from the start of the
    ' message
    '
    If Len(partMsg) < m_Maxlen Then
        str = Mid$(m_msg, 1, m_Maxlen - Len(partMsg))

    Else
        'initialise wrapped part
        If Len(str) Then
            str = ""
        End If
    End If
    'only work on caption  (label/form)
    m_fObject.Caption = partMsg & str
    Exit Sub
    
err_handler:
    If Err.Number = 438 Then
        m_fObject.Text = partMsg & str
    Else
        MsgBox Err.Description & ": " & Err.Number
    End If
End Sub
 
The main program uses a Timer. When the Timer fires, it calls the cRotateCaption objects' rotate methods to make them rotate themselves.
 
Private Sub Timer1_Timer()
    Dim v As Variant
    For Each v In rcCol
        v.rotate
    Next
End Sub
 

Formatted by Neil Crosby

 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated