Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make text scroll like a marquee

A scrolling text box

How do I make text scroll like a marquee

by  gol4  Posted    (Edited  )
Step1 create an unbound textbox or a label
Step2 Paste this code in the forms code section

//////////////////////////////////
'start paste
Private Static Function Scrolltext(Strfield As String) As String
æcall from on timer event
Dim astr As Integer
Dim TextLen As Integer

astr = astr + 1
TextLen = Len(Strfield)
If astr >= TextLen Then astr = 1
Scrolltext = Mid([Strfield], astr, Len([Strfield])) & " " & Left([Strfield], astr)

End Function

end paste
////////////////////////////////////
Step 3 Call the function from the forms on timer event
For any text
Me!text1.text = Scrolltext("Hello World") 'Refer to the unbound text box

For a label
Me.label1.caption = Scrolltext("Hello World")

To use data from a field

Me.text1.text= Scrolltext(me.fieldname) or me.label1.caption = scrolltext(me.fieldname)

Step 4 set the forms timer interval. The higher the number the slower it scrolls around 100 is usually good enough

Step 5 Open the form then sit back and watch your text scroll by.




Spell Out
'spells out word call from timer event
Private Static Function SpellOut(strMessage As String) As String

Dim iCount As Integer
Dim iLen As Integer

iLen = Len(strMessage)
If iCount >= iLen Then iCount = 1

SpellOut = Left(strMessage, iCount)
iCount = iCount + 1

End Function
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top