[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Label slowly moving right to left

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

0
Crystalsoft
Asked:
Crystalsoft
  • 3
  • 2
1 Solution
 
CrystalsoftAuthor Commented:
label is going right to left but very fast i want it slowly moving...How can i do that
0
 
GrahamSkanCommented:
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

0
 
CrystalsoftAuthor 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
0
 
GrahamSkanCommented:
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

0
 
CrystalsoftAuthor Commented:

Thanks Buddy
It's working  :-)
Excellent
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now