Scrolling Text

Hi There,

Unfortunately another vb beginner for you guys here. I am building a windows application and I was wondering if it it possible to display text in a scrolling fashion i.e. with a label scrolling text through it. Like in some news websites where the main headlines would be scrolling along Hope this isn't a silly question

Thanks very much
Colin



Answer this question

Scrolling Text

  • Ian_Ian

    Yes, you can. You need to create a control to do this derive it from the label control and have it store the string internally, as well as a position index. then set a timer and set the text on the control as a substring of the internal string, using the index, which you would increment.

  • dEkS

    Dim x As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    x = Label1.Location.X

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    If x >= -100 Then

    x = x - 10

    Label1.Location = New Point(x, Label1.Location.Y)

    Else

    Label1.Location = New Point(228, Label1.Location.Y)

    x = 228

    End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Label1.Text = TextBox1.Text

    End Sub

    Set the Label location in my example i set to 228. you give any message in textbox then click button, the message will be scroll.this one work when your timer property is true

    send me a reply


  • Hit

    http://www.devarticles.com/c/a/VB.Net/Building-a-News-Ticker-Using-VB.Net/

    is one article I found online.

    Basically, you can create a control derived from the label control, and add code to make it do whatever you like. I'm suggesting adding a timer to control scrollng, and code to change the text within the timer event.



  • korsakow

    Thanks very much for the help.

    Colin


  • MicroMoth

    Hi Christian

    Thanks very much for the reply...ony thing being I'm not entirely sure what you just said. Could you possibly give me an example please.

    Thanks again


  • Scrolling Text