Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2015. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Scrolling Marquee
- '
- ' Author: Joseph L. Bolen
- ' Date Created: Aug 2015
- '
- ' Description: Quick demonstration of how to scroll text within a control or
- ' to move the control across the form.
- '
- ' Documentation is at:
- ' App's Visual Basic .NET code is at http://pastebin.com/wGXY2xPn
- '-------------------------------------------------------------------------------------------
- Public Class MainForm
- Private Sub MainForm_Load(sender As Object, e As EventArgs) _
- Handles MyBase.Load
- ' Adjust interval for speed of scrolling.
- With Timer1
- .Interval = 250
- .Enabled = True
- End With
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) _
- Handles Timer1.Tick
- MovingControl(Label1)
- 'MovingControl(TextBox1)
- 'ScrollingText(Label1)
- ScrollingText(TextBox1)
- End Sub
- ' Move control across form.
- Private Sub MovingControl(ByVal aControl As Control)
- Static xLocation As Integer = aControl.Left
- ' Set new X coordinate
- xLocation -= 5 'move right to left
- ' Graphic off edge of the form; reset it
- If xLocation <= -aControl.Width Then
- xLocation = Me.Width
- End If
- ' Move image
- aControl.SetBounds(xLocation, aControl.Top,
- aControl.Width, aControl.Height)
- End Sub
- ' Scroll text within the control's text property.
- Private Sub ScrollingText(ByVal aControl As Control)
- Dim aString As String = aControl.Text
- aString = Mid(aString, 2, Len(aString) - 1) & Mid(aString, 1, 1)
- aControl.Text = aString
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment