P psevet Member Licensed User Longtime User Mar 20, 2011 #1 Hello, I'm stuck on a problem regarding comparison : in a edittext I enter a value, eg 10 x=1.5 z= 0.5 I want my program to calculate (value1 * x) + (value2 * z) in a loop : for i=1 to 20 for y= 1 to 20 temp=(i * x) + (y * z) if temp<MyEditText.text then Here I want to get the max value beetween the current temp and the previous one, then store the i and y values depending on this comparison in order to keep the maximum value and the corresponding i and y values at the end of both loops. end if next next This would be the way I would deal with this problem, but if I can get another solution I will take it. Thanks for your help. Pierre
Hello, I'm stuck on a problem regarding comparison : in a edittext I enter a value, eg 10 x=1.5 z= 0.5 I want my program to calculate (value1 * x) + (value2 * z) in a loop : for i=1 to 20 for y= 1 to 20 temp=(i * x) + (y * z) if temp<MyEditText.text then Here I want to get the max value beetween the current temp and the previous one, then store the i and y values depending on this comparison in order to keep the maximum value and the corresponding i and y values at the end of both loops. end if next next This would be the way I would deal with this problem, but if I can get another solution I will take it. Thanks for your help. Pierre
Erel B4X founder Staff member Licensed User Longtime User Mar 21, 2011 #2 I think that storing the values in two additional variables is the simplest solution: Code: Dim maxI, maxY, max As Float x=1.5 z= 0.5 for i=1 to 20 for y= 1 to 20 temp=(i * x) + (y * z) if temp<MyEditText.text AND temp > max then max = temp maxI = i maxY = y end if next next Upvote 0
I think that storing the values in two additional variables is the simplest solution: Code: Dim maxI, maxY, max As Float x=1.5 z= 0.5 for i=1 to 20 for y= 1 to 20 temp=(i * x) + (y * z) if temp<MyEditText.text AND temp > max then max = temp maxI = i maxY = y end if next next
P psevet Member Licensed User Longtime User Mar 21, 2011 #3 Thank you very much Erel :sign0060: You're the man ! Hope that Basic4Android makes you rich ! Cheers. Pierre Upvote 0
Thank you very much Erel :sign0060: You're the man ! Hope that Basic4Android makes you rich ! Cheers. Pierre