Scrolling text in a stationary label help needed
- From: jcrouse1@xxxxxxxxxxx
- Date: 16 Sep 2006 09:20:11 -0700
Here is some code I found on the web:
Dim s As Integer
Dim dta As String
Private Sub Form_Load()
Label1.Caption = ""
Timer1.Enabled = True
Timer1.Interval = 100
Label1.Width = 4335
Label1.Font = "Courier New"
Label1.Font.Size = 9
Label1.Font.Bold = True
End Sub
Private Sub Timer1_Timer()
'// put your text here in dta string
dta = "This is a sample of scrolling text in a stationary label." &
Space$(41)
s = s + 1
Label1.Caption = Mid(dta, 1, s)
If Len(Label1.Caption) >= 42 Then Label1.Caption =
Right(Label1.Caption, 41)
If s = Len(dta) Then
Label1.Caption = ""
s = 0
End If
End Sub
THere are a couple of issues. First off, the label width is hardcoded
in the above example. I need to have the code take into account, and
calculate, based on the width of the label, which could change. ALso,
the same with the font size, it and it's properties, size, bold and
italic could change. In the above example the 41 and 42 seem to be the
number of characters that fit in the predefined text box. I need a way
to calculate these. I have looked at the printer.textwidth method but
can't quite get it right. Also, this needs to be done for 5 labels but
I believe I can handle it all in the same timer logic.
Thanks,
John
.
- Follow-Ups:
- Re: Scrolling text in a stationary label help needed
- From: Dmitriy Antonov
- Re: Scrolling text in a stationary label help needed
- Prev by Date: Re: Remove from a collection
- Next by Date: Re: Remove from a collection
- Previous by thread: VOIP SIP Toolkit for VB6 and .NET
- Next by thread: Re: Scrolling text in a stationary label help needed
- Index(es):
Relevant Pages
|