|
-
May 19th, 2005, 11:22 AM
#1
Thread Starter
Addicted Member
timer trouble
HI i have the following code
VB Code:
timer1.enabled = False
'a bit of code
timer1.enabled = True
this executes the code between the timer1, every time its interval is up, so to say.
I want to disable this timer when a button is pressed and enable it again, when another is pressed....
to disable it had
VB Code:
Private Sub command1.click ()
timer1.enabled = False
End Sub
' and to enable it again i had
Private Sub command1.click ()
timer1.enabled = True
End Sub
This didn't work as i have already enabled it in another part of the code
Any Thoughts
Chris Lynch
-
May 19th, 2005, 11:45 AM
#2
Re: timer trouble
You have to disable it if you don't want it to fire. There is no problem with enabling the timer twice. See this code.
VB Code:
Option Explicit
Private Sub Form_Load()
Timer1.Interval = 5000
Timer1.Enabled = True
MsgBox ""
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Beep
End Sub
-
May 19th, 2005, 11:53 AM
#3
Thread Starter
Addicted Member
Re: timer trouble
I think you misunderstand me, i want to disable the timer when i press a command button nut the code i have in post1 is not working?
Chris Lynch
-
May 19th, 2005, 11:55 AM
#4
Re: timer trouble
You had it right:
will disable the timer.
-
May 19th, 2005, 12:06 PM
#5
Thread Starter
Addicted Member
Re: timer trouble
Yes i know that but its not disabling the timer......
-
May 19th, 2005, 12:27 PM
#6
Thread Starter
Addicted Member
Re: timer trouble
I have it thanks
Chris Lynch
-
May 19th, 2005, 12:59 PM
#7
Re: timer trouble
 Originally Posted by Chris Lynch
HI i have the following code
visual basic code:--------------------------------------------------------------------------------
timer1.enabled = False
'a bit of code
timer1.enabled = True
--------------------------------------------------------------------------------
this executes the code between the timer1, every time its interval is up, so to say.
I want to disable this timer when a button is pressed and enable it again, when another is pressed....
to disable it had
visual basic code:--------------------------------------------------------------------------------
Private Sub command1.click ()
timer1.enabled = False
End Sub
' and to enable it again i had
Private Sub command1.click ()
timer1.enabled = True
End Sub
--------------------------------------------------------------------------------
This didn't work as i have already enabled it in another part of the code
Any Thoughts
Chris Lynch
__________________
11 is the magic number
I found this code on the forum and it wrks great in the Click Event of a Command Button:
VB Code:
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Every time the Command button is clicked the enable property will be toggled. Great idea for the person who can up with this idea.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|