Slidding text

G

Guest

Hello.
I'm trying to create a form with a text box that displays the contents of a
certain recordset with the slidding efect. The solution i've found is
displaying character by character with a certain time interval between then.
The problem is that this only works if the textbox has the focus. Can anyone
give me a hint on solving this? The code i'm using is the following:

Option Compare Database
Private rst_alarmes As DAO.Recordset
Private Declare Sub sapisleep Lib "Kernel32" Alias "Sleep" (ByVal
dwMilliseconds As Long)

Private Sub Form_Load()
Set rst_alarmes = CurrentDb.OpenRecordset("Alarmes", dbOpenSnapshot)
Me.TimerInterval = 10000
End Sub

Private Sub Form_Timer()
If rst_alarmes.EOF Then
rst_alarmes.MoveFirst
str_alarme = rst_alarmes!ElementoRede & " - " &
rst_alarmes!Indicador & " - " & rst_alarmes!Valor & " - " & rst_alarmes!data
tam = Len(str_alarme)
For k = tam To 0 Step -1
retira = tam - k
Valor_t = Left(str_alarme, retira)
Me.AlarmesTxt.Value = Valor_t
Call sSleep(100)
Next k
Else
str_alarme = rst_alarmes!ElementoRede & " - " &
rst_alarmes!Indicador & " - " & rst_alarmes!Valor & " - " & rst_alarmes!data
tam = Len(str_alarme)
For k = tam To 0 Step -1
retira = tam - k
Valor_t = Left(str_alarme, retira)
Me.AlarmesTxt.Value = Valor_t
Call sSleep(100)
Next k
rst_alarmes.MoveNext
End If

End Sub

Sub sSleep(lngMillisec As Long)
If lngMillisec > 0 Then
Call sapisleep(lngMillisec)
End If
End Sub
 
R

RD

Hello.
I'm trying to create a form with a text box that displays the contents of a
certain recordset with the slidding efect. The solution i've found is
displaying character by character with a certain time interval between then.
The problem is that this only works if the textbox has the focus. Can anyone
give me a hint on solving this? The code i'm using is the following:

<snip>

I found the following on tek-tips.com. I haven't tried it so I won't
vouch for it.

A scrolling text box
How do I make text scroll like a marquee
faq181-86
Posted: Jun 21, 2000 (Edited Jun 14, 2004)

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])) & &quot;
&quot; & 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top