Okay,
this is probably something quite easy and I'm just not thinking of the solution.
I want to change an angle by 5 deg steps until it reaches the full change.
In other words, if my desired angle is 90, then I want it to understand something like:
If currentangle > desiredangle then
currentangle = currentangle - 5
else if currentangle < desiredangle then
currentangle = currentangle + 5
else if currentangle = desiredangle then
end if
And I want for it to repeat until currentangle = desiredangle.
What am I missing?
Looking forward to gaining a better understanding iLogic and VB.
Will, have a look at this site :http://inventbetter.blogspot.nl/2011/12/using-while-loop-to-backsolve.html there is a good example. One sidenote, i think it's a good idea to add a counter to the While loop with the option to quit the loop. This can prevent that the loop will never end.
Rob.
You may consider at least these 4 options:
Dim Angle As DoubleForEquals 'Debug.Print(vbNewLine & "Method 1") For Angle = 0 To 90 Step 5 'do something ' Debug.Print(CStr(Angle)) Next 'Debug.Print(vbNewLine & "Method 2") For Angle = 90 To 0 Step -5 'do something ' Debug.Print(CStr(Angle)) Next 'Debug.Print(vbNewLine & "Method 3") Angle = 0 ' start value While Angle <= 90 'do something ' Debug.Print(CStr(Angle)) Angle = Angle + 5 End While 'Debug.Print(vbNewLine & "Method 4") Angle = 90 ' start value While Angle >= 0 'do something ' Debug.Print(CStr(Angle)) Angle = Angle - 5 End While
Be careful when compare if X is equal to Y.