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

i set the interval to 0. And it stops!! :mrgreen:

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?

Yeah it should end there, did you ever fix it?

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

:confused:

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.

you could try this one

If X Mod 2 Then
        ' // Odd Number Here
    Else
        ' // Even Number Here
    End If

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
Else
      '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
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

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

I never browse MSDN.

Because I don't have 24 hours internet. and my connection is slow.

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!
w00dy