how to use a timer control in vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vbbeginner07
    New Member
    • Dec 2007
    • 103

    how to use a timer control in vb6

    I have placed a label in a form,i have to move the label from left to right.........h own can i do this uising a timer control........ ..???i need the interval of 1000..........p lease Check.......... ..
    NICK...........
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to handle the TOP and LEFT properties of the label on timer event.

    Comment

    • gobblegob
      New Member
      • Dec 2007
      • 133

      #3
      Hi ,
      This is what i use.


      Add 2 labels tor the form called lblScrollL2R and lblScrollR2L , Set AutoSize =True , Set BackStyle = 0-Transparent.

      Add Timer called TmrScroll and set interval to 50

      DECLARATIONS:

      [CODE=vb]Dim intDeltaX As Integer

      Private Sub Form_Load()
      lblScrollL2R.Le ft = Me.ScaleLeft - lblScrollL2R.Wi dth
      lblScrollR2L.Le ft = Me.ScaleWidth '+ 60
      intDeltaX = 30
      End Sub

      Private Sub TmrScroll_Timer ()
      With lblScrollL2R 'Left to right part
      .Left = .Left + intDeltaX

      If .Left > Me.ScaleWidth Then
      .Left = Me.ScaleLeft - .Width
      End If
      End With
      With lblScrollR2L 'Right to left part
      .Left = .Left - intDeltaX

      If .Left + .Width < Me.ScaleLeft Then
      .Left = Me.ScaleWidth '+ 60
      End If
      End With
      End Sub[/CODE]

      Gobble.
      Last edited by debasisdas; Mar 6 '08, 10:01 AM. Reason: added code=vb tags

      Comment

      • Ali Rizwan
        Banned
        Contributor
        • Aug 2007
        • 931

        #4
        Hi,
        Add a label and a timer to your project and add this code.

        [CODE=vb]Private Sub Form_Load()

        Label1.Left = 0 - Label1.Width
        Label1.Top = 10

        End Sub

        Private Sub Timer1_Timer()

        Label1.Left = Label1.Left + 10

        If Label1.Left > Me.Width + Label1.Width Then
        Label1.Left = 0 - Label1.Width
        End If

        End Sub[/CODE]

        Regards
        >> ALI <<
        Last edited by debasisdas; Mar 6 '08, 11:55 AM. Reason: added code=vb tags

        Comment

        • Vbbeginner07
          New Member
          • Dec 2007
          • 103

          #5
          THANK you all!!!
          IF I HAVE TO BOUNCE BACK THE LABEL FROM APARTICULAR POINT AND MOVES IN THE OPP.DIRECTION.. ......pLEASE hELP ME!!!
          nICK

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Previously was using addition . to move in opposite direction use subtraction.

            Comment

            Working...