How to Auto Scroll Text in a Textbox Using VB.NET

Written by jaime avelar | 13/05/2017
How to Auto Scroll Text in a Textbox Using VB.NET
Learn how to use a timer control in Visual Basic. (Comstock/Comstock/Getty Images)

Creating a Visual Basic.NET application that auto scrolls text in a TextBox control can easily be accomplished using String arrays and a timer. A timer control in VB.NET will execute code continuously until the program ends. Use a String array to fill it with the text you want to scroll, and display different elements of the array in the TextBox using the timer to show the scrolling effect.

Launch Microsoft Visual Studio, click "New Project" from the left pane of your computer screen and expand "Visual Basic" below "Installed Templates." Click "Windows" and double-click "Windows Forms Application" from the centre of the dialogue window to create a new project.

Double-click "Timer" to add one to your form. Double-click "TextBox" to add a new text box to your form. Double-click the form to create a form load event.

Add the following code above the form load event to create three global variables, including the one that will hold your scrolling text:

Dim scrolling Text As String = "This is my scrolling text "

Add the following code inside the form load event to loop through the scrolling text and start the timer:

Switch back to form design view and double-click "Timer1" to create a tick event for the timer. Add the following code inside the event:

Press "F5" to run the program and display scrolling text using the text box.

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.