ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scrolling text (https://www.excelbanter.com/excel-programming/272292-scrolling-text.html)

asukuo

Scrolling text
 
Hi all.
Following Access VBA code, scroll text in a label name lblScroll of a Form.
- Timer interval 250
- On Timer following code:

Private Sub Form_Timer()
Static strMsg As String, intLet As Integer, intLen As Integer
Dim strTmp As String
Const TXTLEN = 40
If Len(strMsg) = 0 Then
strMsg = Space(TXTLEN) & "Welcome all" & Space(TXTLEN)
intLen = Len(strMsg)
End If
intLet = intLet + 1
If intLet intLen Then intLet = 1
strTmp = Mid(strMsg, intLet, TXTLEN)
lblScroll.Caption = strTmp
End Sub

How gets same results in Excel Userform using API ?
Regards, John.



Patrick Molloy[_8_]

Scrolling text
 
Add two buttons - cmdStart and cmdStop to a userform,
plus a label- lblScroll
Add the following code - I used yours without any
changes...


Option Explicit
Private bStop As Boolean
Sub New_Timer()
Dim t As Double
Do
t = Timer
Form_Timer
Do
DoEvents
Loop Until Timer (t + 0.25)
Loop Until bStop
End Sub

Private Sub Form_Timer()
Static strMsg As String, intLet As Integer, _
intLen As Integer
Dim strTmp As String
Const TXTLEN = 40
If Len(strMsg) = 0 Then
strMsg = Space(TXTLEN) & "Welcome all" & _
Space(TXTLEN)
intLen = Len(strMsg)
End If
intLet = intLet + 1
If intLet intLen Then intLet = 1
strTmp = Mid(strMsg, intLet, TXTLEN)
lblScroll.Caption = strTmp
End Sub
Private Sub cmdStart_Click()
bStop=False
Call New_Timer
End Sub
Private Sub cmdStop_Click()
bStop = True
End Sub

ru the form. click the start button to begin scrolling &
the stop button to stop it. Thje keys are (1) the boolean
bStop which is used to control the outer do-loop and
the 'timer' do-loop that controls the wait period after
calling the scrolling sub (ie your code)
Essentially the sub New_Timer replaces the in-built
Access timer.

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----
Hi all.
Following Access VBA code, scroll text in a label name

lblScroll of a Form.
- Timer interval 250
- On Timer following code:

Private Sub Form_Timer()
Static strMsg As String, intLet As Integer, intLen

As Integer
Dim strTmp As String
Const TXTLEN = 40
If Len(strMsg) = 0 Then
strMsg = Space(TXTLEN) & "Welcome all" & Space

(TXTLEN)
intLen = Len(strMsg)
End If
intLet = intLet + 1
If intLet intLen Then intLet = 1
strTmp = Mid(strMsg, intLet, TXTLEN)
lblScroll.Caption = strTmp
End Sub

How gets same results in Excel Userform using API ?
Regards, John.


.


asukuo

Scrolling text
 
Thanks Patrick.
Regards, John.
"Patrick Molloy" ha scritto nel messaggio
...
Add two buttons - cmdStart and cmdStop to a userform,
plus a label- lblScroll
Add the following code - I used yours without any
changes...


Option Explicit
Private bStop As Boolean
Sub New_Timer()
Dim t As Double
Do
t = Timer
Form_Timer
Do
DoEvents
Loop Until Timer (t + 0.25)
Loop Until bStop
End Sub

Private Sub Form_Timer()
Static strMsg As String, intLet As Integer, _
intLen As Integer
Dim strTmp As String
Const TXTLEN = 40
If Len(strMsg) = 0 Then
strMsg = Space(TXTLEN) & "Welcome all" & _
Space(TXTLEN)
intLen = Len(strMsg)
End If
intLet = intLet + 1
If intLet intLen Then intLet = 1
strTmp = Mid(strMsg, intLet, TXTLEN)
lblScroll.Caption = strTmp
End Sub
Private Sub cmdStart_Click()
bStop=False
Call New_Timer
End Sub
Private Sub cmdStop_Click()
bStop = True
End Sub

ru the form. click the start button to begin scrolling &
the stop button to stop it. Thje keys are (1) the boolean
bStop which is used to control the outer do-loop and
the 'timer' do-loop that controls the wait period after
calling the scrolling sub (ie your code)
Essentially the sub New_Timer replaces the in-built
Access timer.

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----
Hi all.
Following Access VBA code, scroll text in a label name

lblScroll of a Form.
- Timer interval 250
- On Timer following code:

Private Sub Form_Timer()
Static strMsg As String, intLet As Integer, intLen

As Integer
Dim strTmp As String
Const TXTLEN = 40
If Len(strMsg) = 0 Then
strMsg = Space(TXTLEN) & "Welcome all" & Space

(TXTLEN)
intLen = Len(strMsg)
End If
intLet = intLet + 1
If intLet intLen Then intLet = 1
strTmp = Mid(strMsg, intLet, TXTLEN)
lblScroll.Caption = strTmp
End Sub

How gets same results in Excel Userform using API ?
Regards, John.


.





All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com