Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timers are stoping my program from working...

Status
Not open for further replies.

visualpanther

Programmer
Dec 17, 2003
7
GB
If I put a timer on my form to move do something lets say make a button appear after a certain ammount of time, the program runs ok, but when you click anywhere on the button or form or even try and click X the computer just responds with a beep. This is annoying as it prevents me from making any programs with timers. Can you tell me how to stop this?
 
Are you sure you're using timers correctly?

It's just that it sounds as though you are in an infinite loop somewhere...

mmilan
 
Yes, the timers are being used correctly, how do I stop the infine loop?
 
Ok here is the complete code for the program
It makes a stick man walk across the bottom of the screen and stop after 5 secs

Timer1
and Timer2 make the 2 stick man images turn on and off.
(giving the illusion of a two framed animation)
Timer3 makes the 2 images go across the screen
Timer4 stops all timers after 5000 millisec.

Private Sub Timer1_Timer()
Image2.Visible = False
Image1.Visible = True
Me.Enabled = False
Timer2.Enabled = True

End Sub

Private Sub Timer2_Timer()
Image1.Visible = False
Image2.Visible = True
Me.Enabled = False
Timer1.Enabled = True

End Sub

Private Sub Timer3_Timer()
Image1.Left = Image1.Left + 100
Image2.Left = Image2.Left + 100
End Sub

Private Sub Timer4_Timer()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
 
What are the intervals for each Timer like. it sounds as if these Timers are always being executed and thus nothing else is getting the opportunity to get executed until all the timers are disabled.

Mark

The key to immortality is to make a big impression in this life!!
 
Timer 1 interval = 200
Timer 2 interval = 200
Timer 3 interval = 200
Timer 4 interval = 5000

 
Me.Enabled should be Timer1.Enabled or Timer2.Enabled whichever is appropriate.
 
Try this code (NO TIMERS), place your images onto a new form, add a command button and the following...

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'makes it sleep


Private Sub Command1_Click()
Dim x As Integer

Image1.Move 100, 100
Image2.Move 100, 100

For x = 0 To 5
Image2.Visible = True
Image1.Visible = False
Image1.Left = Image1.Left + 100
DoEvents
Sleep 200
Image2.Visible = False
Image1.Visible = True
Image2.Left = Image2.Left + 100
DoEvents
Sleep 200
Next x

End Sub
 
"Me" in you timers refers to the hosting form, not the timer - so you are disabling the form...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top