Search code examples
vb.netwinformsmarquee

How to have Marquee kind of text in vb.net?


Is there any way to make the text in a Windows Form to scroll like the text in a marquee tag in HTML?


Solution

  • You can use a timer and a couple of variables to help you do so. Something like this can be done...

    'Class-level variables.
    Private m_intMarqueeCounter As Integer = 1
    Private m_bolMarqueeIncrementUp As Boolean = True
    
    Private Sub YourMarqueeTimer_Tick()
    
       'You can decide what number is best for your app.
       If m_intMarqueeCounter = 10 Then
    
          m_bolMarqueeIncrementUp = False
    
       End If
    
       If m_intMarqueeCounter = 0 Then
    
          m_bolMarqueeIncrementUp = True
    
       End If
    
       Dim intX As Integer
       For intX = 0 to m_intMarqueeCounter
    
          frmYourForm.Text = " " & "Your Title"
    
       Next
    
       If m_bolMarqueeIncrementUp Then
    
          m_intMarqueeCounter += 1
    
       Else
    
          m_intMarqueeCounter -= 1
    
       End If
    
    End Sub