Library code snippets

Scrolling Text

For this example, add a Picture Box (named picHolder) and a Timer (named tmrScroll) to your form. Next, add a label called lblMsg within the Picture Box, and enter a few lines of text into its caption property. Then, add the code below, and run your project!

Private Sub Form_Load()
    lblMsg.Top = picHolder.Height
    tmrScroll.Interval = 10
    tmrScroll.Enabled = True
End Sub
Private Sub tmrScroll_Timer()
    If lblMsg.Top > -lblMsg.Height Then
        lblMsg.Top = lblMsg.Top - 10
    Else
        lblMsg.Top = picHolder.Height
    End If
End Sub

Comments

  1. 24 Jul 2003 at 10:26

  2. 19 Jun 2003 at 16:28

    Here's a slightly better way:


    Code:

    Private Sub picHolder_Click
    tmrScroll.Interval = tmrScroll.Interval XOR 10
    end sub


    This works because 10 XOR 10 = 0, and 0 XOR 10 = 10. You can use any number.

  3. 30 Mar 2003 at 13:33

    By adding a simple code, you can click to start, and click to stop the scrolling:


    Private Sub picHolder_Click()
    If tmrScroll.Interval = 0 Then
    tmrScroll.Interval = 10
    Else
    tmrScroll.Interval = 0
    End If
    End Sub




    -Gaz

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Scrolling Text.

Leave a comment

Sign in or Join us (it's free).