Solved

String scrolling

Posted on 2001-08-05
6
144 Views
Last Modified: 2010-05-02
I'm building an MP3-Player and a CD-Player, now I'm getting the MP3-filename (Songtitle) to scroll on a label.
The problem I would like to solve is: there is a flikkering of the text and the spaces take more time than the actual characters, does anybody know how to get a smooth scroll without these glitches?

This is how I do it:

Private Sub cmdScroll_Click()
lblScroll.Caption = "                        " & txtInput.Text
tmrScrollNow.Interval = 75

End Sub



Private Sub tmrScrollNow_Timer()
   Dim strInputText As String
   Dim i As Integer
   Dim strFirstletter As String
   Dim strTextMinusFirst
   Dim bytLengte As Byte
   Dim strToScroll As String
     
     
 On Error Resume Next
      strInputText = lblScroll.Caption
      bytLengte = Len(strInputText)
      strFirstletter = Left(strInputText, 1)
   strTextMinusFirst = Right(strInputText, (bytLengte -1))
      strToScroll = strTextMinusFirst & strFirstletter
      lblScroll.Caption = strToScroll
      strInputText = strToScroll
 
End Sub


0
Comment
Question by:HeN_da_MaN
6 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 50 total points
ID: 6353018
Best way to get that done is by using a frame. The clipcontrols property of that frame should be set to true. Now in that frame you put a label. You put the text in that label, and then  you decrement or increment the left property of that label. You can use a timer for that.

it would be something like:

Private Sub Timer1_Timer()
   Label1.Left = Label1.Left - 1
   If((Label1.Left + Label1.Width)<0) Then Label1.Left = Frame1.Width
End Sub

Regards,
CJ
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6353043

How about putting a label on a picture box
then moving it
like that


Hi HeN_da_MaN

Private Sub Command1_Click()
lblScroll.Caption = "                        " & txtInput.Text
tmrScrollNow.Interval = 5

End Sub

Private Sub tmrScrollNow_Timer()
  Dim strInputText As String
  Dim i As Integer
  Dim strFirstletter As String
  Dim strTextMinusFirst
  Dim bytLengte As Byte
  Dim strToScroll As String
     
     
On Error Resume Next
 lblScroll.Left = lblScroll.Left - 2
 If lblScroll.Left = -lblScroll.Width Then lblScroll.Left = 0
 
End Sub
yours

0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6353044
Sorry C_J
I did not updated
U R too fast
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 3

Expert Comment

by:andysalih
ID: 6353569
what about doing it like this

Public Str As String
Private Sub Form_Load()
Caption = ""

Timer1.Interval = 200
Str = "Hello, World! "
End Sub

Private Sub Timer1_Timer()
Static x As Integer
If x < Len(Str) Then
x = x + 1
Caption = Caption & Mid(Str, x, 1)
Else    
x = 0
Caption = "" 
End If
End Sub


cheers

hope this helps
andy
0
 
LVL 4

Expert Comment

by:wileecoy
ID: 6353756
HeN_da_MaN

I use your code and it works just fine for me.  No blinking and spaces take the same amount of time as all other numbers & letters.

0
 

Author Comment

by:HeN_da_MaN
ID: 6358227
Thank you,

Hen
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question