Scrolling text in a stationary label help needed



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

.



Relevant Pages

  • RE: how do i make a changed label caption stick
    ... You can either set the label on open every time... ... Private Sub Form_Open ... or if you want you can create a function that opens the form in design mode, ... Public Function SetCaption(strFormName As String, ...
    (microsoft.public.access.formscoding)
  • Re: highlight labels on mouse move
    ... Dim strControlName As String ... Private Function HandleOnMouseMove(ByVal strThisControlName As String) ... Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As ... has several command buttons with the unbounded label next to it. ...
    (microsoft.public.access.formscoding)
  • Re: problem with a Timer control
    ... Public Class MainForm ... Private Sub ... ... > All you need to do is trap the Tick event and set the Label Text to the ... > string strDay = datNow.DayOfWeek.ToString; ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Show Hide Textbox/label
    ... I want the label to be invisible also if the value of the text box is null. ... Private Sub Report_Load ... Dim strRpt As String ...
    (microsoft.public.access.reports)
  • Re: Scrolling text in a stationary label help needed
    ... Dim dta As String ... Private Sub Timer1_Timer ... calculate, based on the width of the label, which could change. ...
    (microsoft.public.vb.general.discussion)