-
I would like to animate something(this is not the problem) I want it to animate it after a cmd button is clicked. How do I get the animation code in the timer sub to animate when a cmd button is clicked. Can I put the animation code directly in the cmd button and some how make the timer know that this code is for it?
Help would be much appriciated,
Thanks,
Marc
-
Unless I understood the problem somehow wrong, just set the timers enabled value to false, and in the button code put:
Timer1.Enabled = 1
Then put the animation code to the timer and remember to set the interval.
-JR-
-
Just Enable the Timer :confused:
Code:
Sub Command1_Click()
Timer1.Interval = 1000 'every second
Timer1.Enabled = True 'activate
'now the timer'll start activating the animation.
End Sub
Anyway, you could also loop it, just a matter of preference.
-
Actually I told to first (in design) set the timer1.enabled to false so it doesn't start doing the animation stuff right when the prog starts.
-JR-
-
But my prob is that I want the animation to start only when a cmd button is clicked this is what the code looks like:
Private Sub cmdSpin_Click()
Timer1.Enabled = 1
If (imgBlur.Left = 4200) And _
(imgBlur.Top > 3120) Then
imgBlur.Left = imgBlur.Left + 0
imgBlur.Top = imgBlur.Top - 50
Else
imgBlur.Left = 2880
imgBlur.Top = 4200
End If
End Sub
Is this right or what is wrong, how can I get the animation to go when the button is clicked
Thanks a bunch,
Marc
-
Maybe this thread will help you a little with your animation?
-
Sleep 1
What is the "sleep 1" mean?
-
Timer1.Enabled = 1
If (imgBlur.Left = 4200) And _
(imgBlur.Top > 3120) Then
imgBlur.Left = imgBlur.Left + 0
imgBlur.Top = imgBlur.Top - 50
Else
imgBlur.Left = 2880
imgBlur.Top = 4200
End If
End Sub
in the command button put :
timer1.enabled = true
in the timer event put :
If (imgBlur.Left = 4200) And _
(imgBlur.Top > 3120) Then
imgBlur.Left = imgBlur.Left + 0
imgBlur.Top = imgBlur.Top - 50
Else
imgBlur.Left = 2880
imgBlur.Top = 4200
End If
End Sub
-
sleep 1 slows the animation down a bit to give it a nice smooth effect, or it will go to fast.
Code:
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
'Adjust to fit your needs
Do Until Image1.Left = 6120
Image1.Left = Image1.Left + 5
Sleep 1
Loop
End Sub
^Just an example, as it says, adjust to fit your needs.
It kind of makes an object move across the form and gives it this cool looking rolling effect. Try it, you might like it :rolleyes:.