We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Label slowly moving right to left

Crystalsoft
Crystalsoft asked
on
Medium Priority
350 Views
Last Modified: 2012-05-06
Hello Experts
I want some animation in my form,  i did some coding also but not getting what i want,
stucked somewhere here.....

Private Sub Timer1_Timer()
    Call showprogress
End Sub
 
Private Sub showprogress()
On Error Resume Next
Dim intcounter As Integer
    Label1.Left = 2400
    For intcounter = 0 To Label1.Left
        Label1.Left = intcounter  ' Update progress.
    Next intcounter
End Sub

Open in new window

Comment
Watch Question

Author

Commented:
label is going right to left but very fast i want it slowly moving...How can i do that
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
You aren't actually using the timer. Try this
Dim intCounter as Integer
Const Limit= 2400
 
Sub Command1_Click()
   intCounter = 0
   Timer1.Interval = 10
   Timer1.Enabled = True
End Sub
 
Private Sub Timer1_Timer()
    Call showprogress
End Sub
 
Private Sub showprogress()
   if intcounter < Limit then
      Label1.Left = intcounter 
   else
      Timer1.Enabled = False
   end if
End Sub

Open in new window

Author

Commented:
not working
actully i want that if lable.left = 2400 when once label moved with slowly than again from left to right moving. and i want it countinuesly,
another thing i want also to changing lable.Backcolor and forecolor also,
Thanks
Retired
CERTIFIED EXPERT
Top Expert 2012
Commented:
This will move the label from to right and then from right to left and change the colours randomly.


Option Explicit
Dim intCounter As Integer
Dim iStep As Integer
Const iRightLimit = 2400
Const iLeftLimit = 0
Dim cIndex As Integer
 
Sub Command1_Click()
   intCounter = 0
   Timer1.Interval = 1
   Timer1.Enabled = True
   iStep = 10
End Sub
 
Private Sub Timer1_Timer()
    Call showprogress
End Sub
 
Private Sub showprogress()
intCounter = intCounter + iStep
    If intCounter > iRightLimit Or intCounter < iLeftLimit Then
        iStep = iStep * -1 'change direction
    End If
    Label1.Left = intCounter
    Label1.BackColor = Rnd * &HFFFFFF
    Label1.ForeColor = Rnd * &HFFFFFF
 
End Sub

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:

Thanks Buddy
It's working  :-)
Excellent
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.