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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping a scroll bar! 1

Status
Not open for further replies.

pleg12345

IS-IT--Management
Dec 21, 2003
48
EU
Please can somebody help?

I have used the code below to build a scroll bar. Could somebody tell me how to stop the text scrolling after twice viewing the message? I would like the text to completely disappear after it has scrolled twice.

code:

Private sub Form_Timer

Static strMsg As String
Static intLet As Integer
Static intLen As Integer
Dim strTmp As String
Const strLen = 40

If Len (strMsg) = 0 Then
strMsg = Space(strLen) & "Welcome to the new system" & Space (strLen)

End If

intLet = intLet +1

If intLet > intLen Thet
intLet = 1

End If

strTmp = Mid(strMsg, intLet, intLen)

Me!lblScroll.Caption(strLen) Then
intLet = 1
End If

End Sub

 
Does this help? Here is my code to achieve a similar effect (modified to scroll the message twice).

Create a label on the form called lblMessage

Define a variable in the 'definitions' section of the form's VBA code:
Code:
Dim strMessage as string
Set the form's timer interval to a value which controls the scroll date, e.g. 100 (milliseconds) will scroll the message at ten characters per second.

In the form's 'On Open' event, set strMessage equal to whatever message you want, e.g.
Code:
strMessage = "My message text ...."
strMessage = strMessage & space$(10) & strMessage
The second line of code 'doubles up' the message and adds ten spaces between the two copies. Change this as required to suit your database.

Finally, add this code to the form's 'On Timer' event:
Code:
Private Sub Form_Timer()
    
If Len(strMessage) > 1 Then
    strMessage = Right$(strMessage, Len(strMessage) - 1)
    Me.lblMessage.Caption = strMessage
    DoEvents
Else
    strMessage = ""
    Me.lblMessage.Caption = strMessage
    Me.TimerInterval = 0
End If

End Sub
When you open the form, the message will appear in the label, scroll to the left, be displayed twice, and then disappear. When the message disappears, the timer is disabled so no further processing takes place.

I hope that this helps.


Bob Stubbs
 
Cheers for the help, but when i open the form nothings happens?

is there any reason why?
 
Just Fixed the Problem, Thanks alot thats great!!!!!!!!!!
 
First, your posted code is missing something, like an IF to start the final END IF, and the DIM for intLen. That being said, if it were me, I'd simply add a For..Next loop with an upper bound of 2, such as:


Private sub Form_Timer

Static strMsg As String
Static intLet As Integer
Static intLen As Integer
Dim strTmp As String
Const strLen = 40


strMsg = Space(strLen) & "Welcome to the new system" & Space (strLen)

strTmp = Mid(strMsg, intLet, intLen)
for i = 1 to 2
Me!lblScroll.Caption(strLen)
next

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top