JayBeeOH

Scrolling Marquee

Aug 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.51 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2015. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Scrolling Marquee
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   Aug 2015
  16. '
  17. ' Description:    Quick demonstration of how to scroll text within a control or
  18. '                 to move the control across the form.
  19. '
  20. '                 Documentation is at:
  21.  
  22. '                   App's Visual Basic .NET code is at http://pastebin.com/wGXY2xPn
  23. '-------------------------------------------------------------------------------------------
  24. Public Class MainForm
  25.  
  26.     Private Sub MainForm_Load(sender As Object, e As EventArgs) _
  27.         Handles MyBase.Load
  28.  
  29.         ' Adjust interval for speed of scrolling.
  30.         With Timer1
  31.             .Interval = 250
  32.             .Enabled = True
  33.         End With
  34.  
  35.     End Sub
  36.  
  37.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) _
  38.         Handles Timer1.Tick
  39.  
  40.         MovingControl(Label1)
  41.         'MovingControl(TextBox1)
  42.         'ScrollingText(Label1)
  43.         ScrollingText(TextBox1)
  44.     End Sub
  45.  
  46.     ' Move control across form.
  47.     Private Sub MovingControl(ByVal aControl As Control)
  48.  
  49.         Static xLocation As Integer = aControl.Left
  50.  
  51.         ' Set new X coordinate
  52.         xLocation -= 5 'move right to left
  53.         ' Graphic off edge of the form; reset it
  54.         If xLocation <= -aControl.Width Then
  55.             xLocation = Me.Width
  56.         End If
  57.         ' Move image
  58.         aControl.SetBounds(xLocation, aControl.Top,
  59.                                    aControl.Width, aControl.Height)
  60.  
  61.     End Sub
  62.  
  63.     ' Scroll text within the control's text property.
  64.     Private Sub ScrollingText(ByVal aControl As Control)
  65.         Dim aString As String = aControl.Text
  66.         aString = Mid(aString, 2, Len(aString) - 1) & Mid(aString, 1, 1)
  67.         aControl.Text = aString
  68.     End Sub
  69. End Class
Advertisement
Add Comment
Please, Sign In to add comment