Turn a Textbox or Label Into a Marquee

Turn a Textbox or Label Into a Marquee

Sometimes you need to display information longer than the biggest textbox or label control you can have onscreen. I’ve written a routine that displays a textbox’s or label’s contents in marquee style, with the text moving from right to left. Animate your controls by adding a timer to the form and setting its Interval property to 250 (to update the display four times per second). On each timer tick, pass the control you want to animate to the ShiftChars routine. This routine works by reading the control’s contents, shifting the first character to the end, and reassigning the contents:

 lPrivate Sub Timer1_Timer()	Call ShiftChars(Text1)	Call ShiftChars(Label1)End SubPrivate Sub ShiftChars(ctl As Control)	Dim Buffer As String	Select Case TypeName(ctl)		Case "TextBox", "Label"			' Rely on default property to accept/return contents.			Buffer = ctl			If Len(Buffer) > 1 Then				ctl = Mid$(Buffer, 2) & Left$(Buffer, 1)			End If	End SelectEnd Sub

For a more natural display, make sure your text strings have a trailing space character.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several