Results 1 to 4 of 4

Thread: Scrolling Text

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367

    Question

    How can I scroll text? Do I need to use BitBlt? Is there a control that does this already?

    I would like to create text that would scroll from right to left across my form, sorta like a stock quote ticker.

  2. #2
    Guest
    i did it once with a timer and Courier-New font, i just incremented the 'start' argument of an INSTR() function, and sent that clip of text to a label.

    It isn't the smoothest but at least the letters jump along at a uniform pace!


  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ...a couple of examples

    example 1

    'scrolling text
    'need 1 label, 1 timer, 1 command button for this example
    '
    Option Explicit

    Private Sub Command1_Click()

    'will give user a Yes or No prompt in which they wish to exit

    Dim x As Integer
    x = MsgBox("Are you sure you want to exit?", vbYesNo, "Exit")

    If x = 6 Then
    End
    End If

    End Sub

    Private Sub Form_Load()
    'Will modify all the following controls when the project is run o
    ' r loaded

    dim msg$ as string

    msg$ = "This is a simple Marquee example that I've made." & vbCrLf
    msg$ = msg$ & "You can make something 100 times better."
    MsgBox msg$, vbYes, "Marquee Example of Scrolling Text"



    Label1.Visible = True
    Label1.Enabled = True


    Form1.Enabled = True
    Label1.Caption = Date
    Label1.Left = 0
    Label1.Top = 1800
    Label1.Height = 255
    Label1.Width = 1195

    Command1.Top = 2400
    Command1.Left = 0
    Command1.Height = 375
    Command1.Width = 6705
    Command1.Caption = "Exit Example"
    Command1.Enabled = True
    Command1.Visible = True


    Form1.Height = 3225


    Form1.Width = 6810
    Timer1.Enabled = True
    Timer1.Interval = 1

    End Sub

    Private Sub Timer1_Timer()

    If Label1.Left < -1000 Then
    Label1.Left = 7000
    Else
    Label1.Left = Val(Label1.Left) - 40
    End If

    End Sub

    '''''''''''''''''''''''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''''

    'example 2

    'scrolling text...
    'scrolls once from the bottom of the picture box
    'to the top of the box
    ' requires a picture box and a timer control
    '(timer ctrl propery enabled set to false)
    '
    Option Explicit
    '
    'Text string to be scrolled
    Public strString As String

    'Last position of text
    Public IntLPosition As Integer

    Private Sub Form_Load()
    '
    'strString = the text you want scrolled
    '
    strString = "This is a scrolling text example." & vbCrLf
    strString = strString & "The life and times of me!" & vbCrLf
    strString = strString & "As if there was a tale." & vbCrLf
    strString = strString & "Who, but you, would you tell it to?"
    '
    IntLPosition = Picture1.Height 'Start at bottom
    Timer1.Interval = 50 'time between scrolling (lower number faster speed)
    Timer1.Enabled = True 'Start timer
    '
    End Sub

    Private Sub Timer1_Timer()

    Picture1.Cls 'Clear picture box
    Picture1.CurrentY = IntLPosition 'Set position
    Picture1.Print strString 'Show
    IntLPosition = IntLPosition - Screen.TwipsPerPixelY 'Move up one pixel
    If IntLPosition < 0 Then Timer1.Enabled = False 'Stop when at top
    End Sub





    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535

    Talking

    You can download my "Scroll Text ActiveX control" from http://www.planetsourcecode.com/vb in the COM/DCOM?Activex section.

    Don't forget to rate it. Please.


    Kinjal

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