readmedottxt 1 Posted April 27, 2010 Here's my predicament - I have a script that uses a counter in a loop, eg: $i = $i + 1 I need a trigger once every three, five and seven numbers. Is there a function to do this or would i need to divide $i by the trigger and work out if its a whole number? Thanks Share this post Link to post Share on other sites
readmedottxt 1 Posted April 27, 2010 Here's my predicament - I have a script that uses a counter in a loop, eg: $i = $i + 1 I need a trigger once every three, five and seven numbers. Is there a function to do this or would i need to divide $i by the trigger and work out if its a whole number? Thanks This does work, but is it the best way to do it? $RetVal = $i / 5 if Round($RetVal) = $RetVal Then GUICtrlSetData($Report, "Increment: " & $i) EndIf Share this post Link to post Share on other sites
omikron48 0 Posted April 27, 2010 Try using the modulo (remainder). For $i = 1 To 10 If Mod($i, 3) == 0 Then MsgBox(0x2000, "3rd Number", $i) ElseIf Mod($i, 5) == 0 Then MsgBox(0x2000, "5th Number", $i) ElseIf Mod($i, 7) == 0 Then MsgBox(0x2000, "7th Number", $i) EndIf Next Share this post Link to post Share on other sites
readmedottxt 1 Posted April 27, 2010 (edited) Try using the modulo (remainder). For $i = 1 To 10 If Mod($i, 3) == 0 Then MsgBox(0x2000, "3rd Number", $i) ElseIf Mod($i, 5) == 0 Then MsgBox(0x2000, "5th Number", $i) ElseIf Mod($i, 7) == 0 Then MsgBox(0x2000, "7th Number", $i) EndIf Next I hadn't used modulo since leaving school! Thank you - it's applied a solution in a very intelligent way. Edited April 27, 2010 by readmedottxt Share this post Link to post Share on other sites