How To Make Scrolling Text In Textbox And Label In VB.NET

this is a good snippet and this will be very useful for you , lets start

1.open visual basic 2008/2010

2. create a new project

3. add a textbox and a timer

4. enable the timer

5.write something in the textbox (textbox1 > properties > text )
6.double click your form and erase everything and paste the code below

Public Class Form1

    Public Function MarqueeLeft(ByVal Text As String)
        Dim Str1 As String = Text.Remove(0, 1)
        Dim Str2 As String = Text(0)
        Return Str1 & Str2
    End Function
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        textbox1.Text = MarqueeLeft(textbox1.Text)
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub
End Class

7. now debug and enjoy the text , textbox scrolling

8.if you want to make this to label simply add a label and write something(label1>properties>text) and paste this code

Public Class Form1
    Public Function MarqueeLeft(ByVal Text As String)
        Dim Str1 As String = Text.Remove(0, 1)
        Dim Str2 As String = Text(0)
        Return Str1 & Str2
    End Function
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = MarqueeLeft(Label1.Text)
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub
End Class

9.debug and enjoy the text , label scrolling

11 comments

Very useful, thank-you!

Reply

Thank You This is really useful thx GBU

Reply
Anonymous mod

thanks

Reply

How would you get the text to scroll more smoothly? Instead of groupings of text.

Reply

You have that many ads on your site I can barely see what Im trying to read.

Reply

Could you please tell how to add a text file so that the contents would be fetched and displayed and its moving smootly.

Reply

Could you please tell how to add a text file so that the contents would be fetched and displayed and its moving smootly.

Reply

I set the size of textbox width same as Screen.PrimaryScreen.Bounds.Width, then the text in textbox only display start from half of box..Do you know how to set the length size of textbox.text equal to size textbox?

Reply

I already know how to solve this.... Actually i put wrong syntax code when i read and execute data from sql...my bad... by the way thank u for coding above, it very useful for me

Reply

Post a Comment

Note: Only a member of this blog may post a comment.