Hi all,
Here's what's happening:
I have a counter that increments by 1 and then checks some frequencies to see if it should trigger at that time.
The problem is, my check is in the form of "If Math.Round(intCounter Mod Frequency) = 0 Then ..."
This works fine for nice numbers, but when the frequency is, let's say, 100/3, then things don't work out quite right.
The program triggers on 67 and 100, but not on 33 because 33.33333... > 33 and 33 Mod 100/3 is not close to 0.
I can get it to trigger on 33 by rounding first, but that also means that the program will trigger on 66 and 99 instead of
67 and 100, which is what it should do.
Any suggestions?
Thanks.
Here's what's happening:
I have a counter that increments by 1 and then checks some frequencies to see if it should trigger at that time.
The problem is, my check is in the form of "If Math.Round(intCounter Mod Frequency) = 0 Then ..."
This works fine for nice numbers, but when the frequency is, let's say, 100/3, then things don't work out quite right.
The program triggers on 67 and 100, but not on 33 because 33.33333... > 33 and 33 Mod 100/3 is not close to 0.
I can get it to trigger on 33 by rounding first, but that also means that the program will trigger on 66 and 99 instead of
67 and 100, which is what it should do.
Any suggestions?
Thanks.
Last edited: