Hello boys and girls! :wave:
This is my first vb.net tutorial. I plan on making a series, covering things such as SMTP-handling, FTP, webRequests, proxys, obfuscation, and general tips & tricks.
This tutorial will show you how to make a vertical scrolling text. You will be able to easily change the scrolling speed, area of scrolling and so forth.
This is great for things like credits, news-tickers or just making things look damn cool.
To begin, add the following components to your Form1.
(Component, Name of component)
1 picturebox, PicHolder
1 timer, tmrScroll
1 label, lblMsg
Layout
First, place PicHolder on your form. Choose "Dock in parent container", or make it any size you like. The size of the picturebox does not change the way we will code the scrolling!
Secondly, place lblMsg inside PicHolder. In the properties of lblMsg, choose textalign=middle. Then write "Hello world" and align it in the middle of PicHolder (middle of PicHolder = PicHolder.width/4).
Code
Doubleclick on the menubar of Form1 to go into the code editor and the sub Form1_Load, then we write the following code:
Code:
tmrScroll.Interval = 20
Tmrscroll.Enabled = True
lblMsg.Top = PicHolder.Height
The interval of TmrScroll will determine how fast the text scrolls. Play around with it to find a value you like (usually between 10-30). After the timer-settings, we set the top of lblMsg to the height of PicHolder. You will understand this in the next step.
Doubleclick on tmrScroll to go into the sub tmrScroll_Tick and write this:
Code:
If lblMsg.Top > -lblMsg.Height Then
lblMsg.Top = lblMsg.Top - 1
Else
lblMsg.Top = PicHolder.Height
End If
As you can see, it performs a check on where the lblMsg's position is relative to the height of PicHolder, and performs a slight change of the values which results in the smooth movement of the text within PicHolder.
And we are all done! Remember, you change the speed of the text by changing the Interval of tmrScroll in the Form1 loadevent. To make sure you understand this tutorial, make the text scroll horizontally!