VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Continuously scrolling, centered text in a PictureBox. Just put a picture box and a timer control o

by DiskJunky (16 Submissions)
Category: Graphics
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th November 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Continuously scrolling, centered text in a PictureBox. Just put a picture box and a timer control on a form and paster the following code into

Rate Continuously scrolling, centered text in a PictureBox. Just put a picture box and a timer control o



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
End Sub


Download this snippet    Add to My Saved Code

Continuously scrolling, centered text in a PictureBox. Just put a picture box and a timer control o Comments

No comments have been posted about Continuously scrolling, centered text in a PictureBox. Just put a picture box and a timer control o. Why not be the first to post a comment about Continuously scrolling, centered text in a PictureBox. Just put a picture box and a timer control o.

Post your comment

Subject:
Message:
0/1000 characters