|
-
Mar 10th, 2002, 11:07 AM
#1
Thread Starter
Frenzied Member
Scrolling Text
How can i make the text in a text box/label scroll?
-
Mar 10th, 2002, 11:22 AM
#2
Frenzied Member
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.
"If at first you don't succeed, then skydiving is not for you"
-
Mar 10th, 2002, 02:24 PM
#3
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
-
Mar 10th, 2002, 02:47 PM
#4
Thread Starter
Frenzied Member
Thanks hack. The mega-mans example was great, don't get me wrong, but this was just what i was looking for.
-
Mar 12th, 2002, 12:38 PM
#5
Thread Starter
Frenzied Member
is there any way of scrolling multi lined messgaes?
-
Mar 12th, 2002, 12:45 PM
#6
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
-
Mar 12th, 2002, 02:08 PM
#7
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|