Stopping a timer

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2005
Posts: 3
Reputation: nathanoverall is an unknown quantity at this point 
Solved Threads: 0
nathanoverall nathanoverall is offline Offline
Newbie Poster

Stopping a timer

 
0
  #1
Sep 23rd, 2005
I have a program in which a series of events occir each time the timer runs. However i want to stop the timer when a certain variable reaches another variable. I have tried

If variable1 = variable 2 then
timer.enabled = false

but the timer continues. Why is this. If anyone has a resolution can u demonstrate it with the example above. Thanx
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 3
Reputation: nathanoverall is an unknown quantity at this point 
Solved Threads: 0
nathanoverall nathanoverall is offline Offline
Newbie Poster

Re: Stopping a timer

 
0
  #2
Sep 23rd, 2005
i set the interval to 0. And it stops!! :mrgreen:
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Stopping a timer

 
0
  #3
Sep 23rd, 2005
Timer.Enabled = False works for me, there should be no need to work round it like that. Did you follow that with an Exit Sub? If not, then the rest of the sub will execute, maybe something in there enables it again?
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 10
Reputation: The_Inferno is an unknown quantity at this point 
Solved Threads: 0
The_Inferno The_Inferno is offline Offline
Newbie Poster

Re: Stopping a timer

 
0
  #4
Oct 4th, 2005
Yeah it should end there, did you ever fix it?
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 3
Reputation: nathanoverall is an unknown quantity at this point 
Solved Threads: 0
nathanoverall nathanoverall is offline Offline
Newbie Poster

odd or even?

 
0
  #5
Oct 7th, 2005
Thanks for your help guys. Problem Solved.

I have another prob now though. I now need to do something if a number is odd or Even.

If variable 1 is even then...

Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Stopping a timer

 
0
  #6
Oct 8th, 2005
Say your variable is called x.

If x / 2 = Int(x / 2) then it's even, otherwise it's odd. That should work for you. The Int function rounds down to the nearest whole number.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 464
Reputation: invisal is a jewel in the rough invisal is a jewel in the rough invisal is a jewel in the rough 
Solved Threads: 49
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: Stopping a timer

 
0
  #7
Oct 8th, 2005
you could try this one

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If X Mod 2 Then
  2. ' // Odd Number Here
  3. Else
  4. ' // Even Number Here
  5. End If
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Stopping a timer

 
0
  #8
Oct 8th, 2005
Hi, Invisal, I know I should have done a proper example, like

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If x / 2 = Int (x / 2) Then
  2. 'it's even so do something
  3. Else
  4. 'it's odd, so do something else
  5. End if

Just wondering about that 'Mod 2'. Haven't seen it before, can you explain?
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 464
Reputation: invisal is a jewel in the rough invisal is a jewel in the rough invisal is a jewel in the rough 
Solved Threads: 49
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: Stopping a timer

 
0
  #9
Oct 8th, 2005
It will return remainder from division of 2 numbers
example

a = 10 mod 3 ' // a = 1
a = 11 mod 3 ' // a = 2
a = 3 mod 3 '// a = 0
a = 12 mod 3 '// a = 0
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 70
Reputation: w00dy is an unknown quantity at this point 
Solved Threads: 2
w00dy w00dy is offline Offline
Junior Poster in Training

Re: Stopping a timer

 
0
  #10
Oct 9th, 2005
Thanks for that, Invisal
The Mod operator isn't mentioned in any of the books I have. I suppose I should browse MSDN more!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC