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

12 Years
Discussion Span
Last Post by w00dy

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?


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...



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.


Hi, Invisal, I know I should have done a proper example, like

If x / 2 = Int (x / 2) Then
      'it's even so do something
      'it's odd, so do something else
End if

Just wondering about that 'Mod 2'. Haven't seen it before, can you explain?


It will return remainder from division of 2 numbers

a = 10 mod 3 ' // a = 1
a = 11 mod 3 ' // a = 2
a = 3 mod 3 '// a = 0
a = 12 mod 3 '// a = 0


Thanks for that, Invisal
The Mod operator isn't mentioned in any of the books I have. I suppose I should browse MSDN more!


Aah...thought you meant you didn't like it, actually I don't, but lets face it, all the info seems to be there if you can find it. Anyway, thanks for enlightening me, I'm sure it won't be the last time!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.