[RESOLVED] form caption title move & move??
does everybody who can provide source code let me know how to make form caption title move & move??
add a timer control to count it moving.
caption title from left side move to right side, then form right side move to left side. repeat and repeat.
thanks!
here is small example which is title run & run, but I need it move & move.:
Code:
Public tit1 As String
Private Sub Form_Load()
tit1 = "This title can run and run!.......... "
Form1.Caption = title1
Timer1.Interval = 200
End Sub
Private Sub Timer1_Timer()
L = Len(tit1)
tit1 = Mid(tit1, 2, L - 1) + Left(tit1, 1)
Form1.Caption = tit1
End Sub
Re: form caption title move & move??
I assume you mean a scrolling marquee...but what do you mean by "move and move"?
BTW, the three lines in the timer1_timer:
Code:
L = Len(tit1)
tit1 = Mid(tit1, 2, L - 1) + Left(tit1, 1)
Form1.Caption = tit1
Can be done in one line, like so
Code:
form1.caption = Mid(form1.caption, 2) & Left(form1.caption, 1)
and also notice there I replaced the + with a &...NEVER use + when joining strings, it's always & for string and + for numbers :-P
In fact, I think that will *fix* the problem you've been having...because if you look at your code you don't set tit1 properly each time timer1 is called, it needs to be updated with the new form caption string before you repeat the scroll...so using the new line I gave you above should work fine
Re: form caption title move & move??
move to here, go right side|← ← ← ← ← title here → → → → →| move to here, go left side.
which mean is title can left and right side moving.
Re: form caption title move & move??
You mean like this?
Code:
Option Explicit
Private Const THE_CAPTION As String = "Title does move and move (?)"
Private Const RIGHT_BOUNDS As Long = 1200
Private strNewCap As String
Private intDir As Integer
Private Sub Form_Load()
strNewCap = THE_CAPTION
intDir = 1
Timer1.Interval = 50
Me.Width = 500 * Screen.TwipsPerPixelX
Me.Height = 500 * Screen.TwipsPerPixelY
End Sub
Private Sub Timer1_Timer()
If intDir = 1 Then
strNewCap = " " & strNewCap
If TextWidth(strNewCap) >= (Me.Width - RIGHT_BOUNDS) Then intDir = 0
Else
strNewCap = Mid$(strNewCap, 2)
If Len(strNewCap) = Len(THE_CAPTION) Then intDir = 1
End If
Me.CAPTION = strNewCap
End Sub
Re: form caption title move & move??
Quote:
Originally Posted by smUX
and also notice there I replaced the + with a &...NEVER use + when joining strings, it's always & for string and + for numbers :-P
& is designed to join text and numbers together. Try it and see:
msgbox "The total is" & 4
It is also slower than + because it converts everything internally to a variant.
+ does different things depending on the data type. Strings it appends and numbers it sums.:cool:
Re: form caption title move & move??
many thanks to DigiRev, this just what I want.
Very excellent code, you did good job!
cheers!