Results 1 to 6 of 6

Thread: [RESOLVED] form caption title move & move??

  1. #1

    Thread Starter
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    Resolved [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
    Last edited by cxj98; Jun 1st, 2007 at 07:16 PM.

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    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
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  3. #3

    Thread Starter
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    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.

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    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.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6

    Thread Starter
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    Re: form caption title move & move??

    many thanks to DigiRev, this just what I want.

    Very excellent code, you did good job!

    cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width