If you have an infinite loop, use control-break to pause the program.
After you pause the program, pay attention to the line that is highlighted in the VB IDE. This line is a part of the infinite loop. Then, figure out how deeply this line is embedded in loops.
This line of code can be nested in a loop that is also embedded in another loop. The infinite loop can be the inner loop (the one enclosing the line immediately), or the outer loop.
To differentiate who loop is infinite, place a break point immediately after the end of the inner loop, then continue execution. If the program is still stuck in an infinite loop, it means the inner loop is infinite. If the program pauses at the break point, then the inner loop is not infinite. You can, then, remove the break point, and set up a new one after the end of the out loop (assuming that you have yet another outer-outer loop).
When you debug infinite loops, pay attention to the condition of the loop. With a Do While loop, the condition stays true all the time. With a Do Repeat loop, the condition stays false all the time. Look for code inside that loop that affects the condition of the loop. If you don’t find any such code, that means that the condition cannot change!
Other common mistakes that lead to infinite loops include the use of disjunction instead of conjunction in a Do While loop, or vice versa in a Do Repeat loop.