Want another type of scrolling? Here we go:
VB Code:
Private Sub Timer1_Timer() Static A As Integer, B As Boolean 'this code will change the caret's position inside the textbox 'first check there is text in the textbox; if not, just exit If Len(Filename.Text) = 0 Then Exit Sub 'then move caret back or forward depending of the direction 'if B = True then move caret left, if False then to the right If B Then A = A - 1 Else A = A + 1 'check we're not overlapping If A >= Len(Filename.Text) And Not B Then A = Len(Filename.Text): B = True If A <= 0 And B Then A = 0: B = False 'and now, lastly, move the caret Filename.SelStart = A End Sub
This will scroll text back and forward if the text is longer than the textbox. If it isn't, the text doesn't scroll. If you wish to hide the caret, look for HideCaret and ShowCaret API :)
The code you provided would work better with a label with AutoSize = True, since you require extra coding to get the length of the text in the textbox and resize it accordingly. Also, instead of using hard coded values such as -2160, you could use -Filename.Width and FrameTheFilenameIsIn.Width. And the code above I posted might give some ideas to enhance it in other way as well :)
Heh, you can make up a lot of text just of a text scrolling! :D
