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).

James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...
AddThis

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

We'd love to hear what you think! Submit ideas or give us feedback