Results 1 to 3 of 3

Thread: News Ticker

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    9

    Post

    I need to make a scrolling ticker for my application be it in a label or not. I need something that polls the database of news and displays the latest on the bottom. Also I would like to have each item be linked to open another form in my application to show the whole story.

    The database stuff I don't really need help with, but I need to know how to make it continually move and display everything I tell it to display one record at a time.

    Thanks in advance

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post

    Well, I have done a few things with scrolling text, but not that much. Here is one way to have a label that scrolls a message.

    Create a form and place a timer and a label on it (the label should be about 4" wide or so for this example). Make sure that the Alignment property for the label is set to "1 - Right Justify".

    Then place the following code into the form's code window:
    Code:
    Option Explicit
    
    Private sMsg As String                  'Holds the scrolling message text
    Private nStartPos As Integer            'Counter
    Const nTextDisplayLen As Integer = 50   'Width of text to display
    
    Private Sub Form_Load()
        'I create a long message here. You will access your db and add text
        'from records into sMsg string instead.
        sMsg = "Hello, how are you today? "
        sMsg = sMsg & "I am fine. "
        sMsg = sMsg & "Nice weather we're having. "
        sMsg = sMsg & "Did you catch the game last night? "
    End Sub
    
    Private Sub Timer1_Timer()
        nStartPos = nStartPos + 1
        
        'This is where you would check for new news items to add to your
        'string...I just made up function names to show how code would flow
        'If IsNewMessage() Then
        '    sMsg = sMsg & GetNewMessage()
        'End If
        
        'You may want to delete the oldest news item if string gets too long
        'You will have to figure that out yourself!!!
        
        If nStartPos > Len(sMsg) Then
            nStartPos = 1
        End If
        
        Label1 = Right$(Label1 & Mid$(sMsg, nStartPos, 1), nTextDisplayLen)
    End Sub
    This scrolls the message from right to left. The constant nTextDisplayLen determines how many characters of the scrolling text are displayed in your label. You can adjust this to whatever works for your label length.

    Adjust the timer Interval property to change the rate of scrolling.

    Hope this helps!

    ~seaweed

  3. #3
    scobiej
    Guest

    1 last question

    Just had a look @ that code. I've got similar on my prototype but I need the links to be a http link to a web page.

    I'm 90% sure i'll need to use a 3rd party control, however, do you know if it can be done just in VB so I can keep the app size down.

    Thanks for reading

    john

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width