Gunther Active Member Licensed User Longtime User Feb 27, 2014 #1 Dear all, sometimes you need to check divisons with rest value. The operator of Modulo (a mod b) = c is not implemented in B4A. This function is easily giving this rest value but is done as a function: Code: ' calculates (A mod B) and giving the rest Sub Modulo(intA As Int, intB As Int) As Int If intB = 0 then return ' Return intA - Floor(intA / intB) * intB ' End Sub Example: Code: Msgbox(Modulo(34, 3),"") Result: 1 (since 11 * 3 = 33 rest 1) Last edited: Feb 28, 2014
Dear all, sometimes you need to check divisons with rest value. The operator of Modulo (a mod b) = c is not implemented in B4A. This function is easily giving this rest value but is done as a function: Code: ' calculates (A mod B) and giving the rest Sub Modulo(intA As Int, intB As Int) As Int If intB = 0 then return ' Return intA - Floor(intA / intB) * intB ' End Sub Example: Code: Msgbox(Modulo(34, 3),"") Result: 1 (since 11 * 3 = 33 rest 1)
Gunther Active Member Licensed User Longtime User Feb 28, 2014 #3 Klaus right! But is not referred in the help! Thanks anyhow. Last edited: Feb 28, 2014 Upvote 0