How can i make the text in a text box/label scroll?
Printable View
How can i make the text in a text box/label scroll?
Put some text in a label and add the following code to a timer with interval set to 100
VB Code:
Label1.Caption = Right$(Label1.Caption, Len(Label1.Caption) - 1) & Left$(Label1.Caption, 1)
Mega.
VB Code:
'Put a Timer and a Picture Box on the form 'Set the Timer Interval to 3 'Add the following code to the Timer1_Timer event Const MyStr = "Hello, this is a test string" Static TopText As Integer Static TopLoaded As Boolean Dim Speed As Integer Dim NotShowing As Long 'speed is one pixel per tick Speed = Screen.TwipsPerPixelY If Not TopLoaded Then 'only set this once TopText = Picture1.ScaleHeight TopLoaded = True End If 'clear picture box text Picture1.Cls 'center the text about to be displayed Picture1.CurrentY = TopText Picture1.CurrentX = (Picture1.ScaleWidth \ 2) - (Picture1.TextWidth(MyStr) \ 2) 'display text Picture1.Print MyStr 'if text has moved past the top of the picture box 'then start scrolling text from the bottom NotShowing = (TopText + Picture1.TextHeight(MyStr)) If NotShowing < 0 Then TopText = Picture1.ScaleHeight Else 'else continue moving text up TopText = TopText - Speed End If
Thanks hack. The mega-mans example was great, don't get me wrong, but this was just what i was looking for.
is there any way of scrolling multi lined messgaes?
VB Code:
Private Sub Timer1_Timer() 'Put a Timer and a Picture Box on the form 'Set the Timer Interval to 3 'Add the following code to the Timer1_Timer event Dim MyStr As String MyStr = "Here is comes to save the day..." & vbCrLf MyStr = MyStr & Space(15) & "Good ole Hack is on the way.!" Static TopText As Integer Static TopLoaded As Boolean Dim Speed As Integer Dim NotShowing As Long 'speed is one pixel per tick Speed = Screen.TwipsPerPixelY If Not TopLoaded Then 'only set this once TopText = Picture1.ScaleHeight TopLoaded = True End If 'clear picture box text Picture1.Cls 'center the text about to be displayed Picture1.CurrentY = TopText Picture1.CurrentX = (Picture1.ScaleWidth \ 2) - (Picture1.TextWidth(MyStr) \ 2) 'display text Picture1.Print MyStr 'if text has moved past the top of the picture box 'then start scrolling text from the bottom NotShowing = (TopText + Picture1.TextHeight(MyStr)) If NotShowing < 0 Then TopText = Picture1.ScaleHeight Else 'else continue moving text up TopText = TopText - Speed End If End Sub
thanks hack