Hi there, i want to make a program that has a label and i want that label to move from right to left and do it again and again by using timer if its possible, for example: i want it like an electric commercials in some shops or posters...the text goes from right to left and start again.

and please don't just right the codes, tell me how many timers should i use...I hope your answer is clear.


Thanks :icon_smile:

Option Explicit
   Private Const MARQUEE = "This is a scrolling Marquee."
   Dim intLength As Integer
   Dim strMarquee As String

Private Sub Form_Load()
   lblMarquee.Caption = MARQUEE
   intLength = Len(MARQUEE)
   strMarquee = MARQUEE
End Sub


Private Sub tmrMarquee_Timer()
   Dim strFirstCharacter As String
   ' Find the current first character
   strFirstCharacter = Mid$(strMarquee, 1, 1)
   ' Remove the First Character
   strMarquee = Right(strMarquee, intLength - 1)
   ' Add it to the end
   strMarquee = strMarquee & strFirstCharacter
   lblMarquee.Caption = strMarquee
End Sub

You just need to ensure that your timer is enabled and have the interval property set to something like 750 (milliseconds). You can get by with one timer. In this example, the timer's name is tmrMarquee

Hank

I think this is still the quickest way

'Add a label and a timer to form.
'Set timer enabled property to false.
'Set timer interval property to the speed you would like the text to be
'scrolled at i.e 150 etc.
'Get the left property of the label up to where you want it to scroll to
'i.e. furtherest left normally a minus (-480) and furtherest right normally
'a positive (7920)

'************** -------------------- *******************

[Private Sub Form_Load()]

[Label1.Left = 7920 'label to start scrolling at from right]

[Timer1.Enabled = True]
[End Sub]

[Private Sub Timer1_Timer()]

[If Label1.Left = -480 Then]
[Label1.Left = 7920 'Reset label to right AFTER most left reached]
[Else]
[Label1.Left = Label1.Left - 50 'Change 50 to whatever distance text is to scroll]

[End If]

[Timer1.Enabled = False]

[Timer1.Enabled = True]
[End Sub]

Hope this helps...

I think this is still the quickest way

'Add a label and a timer to form.
'Set timer enabled property to false.
'Set timer interval property to the speed you would like the text to be
'scrolled at i.e 150 etc.
'Get the left property of the label up to where you want it to scroll to
'i.e. furtherest left normally a minus (-480) and furtherest right normally
'a positive (7920)

'************** -------------------- *******************

[Private Sub Form_Load()]

[Label1.Left = 7920 'label to start scrolling at from right]

[Timer1.Enabled = True]
[End Sub]

[Private Sub Timer1_Timer()]

[If Label1.Left = -480 Then]
[Label1.Left = 7920 'Reset label to right AFTER most left reached]
[Else]
[Label1.Left = Label1.Left - 50 'Change 50 to whatever distance text is to scroll]

[End If]

[Timer1.Enabled = False]

[Timer1.Enabled = True]
[End Sub]

Hope this helps...

Thanks :) for the code

No problem....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.