OK. In this example, the only thing that happens/changes when you press the escape key is that it sets the oBody variable's Value to 'Nothing', instead of a SurfaceBody object. Then your next line of code after the Pick function, is checking to see if the oBody variable 'Is Nothing', which will be True if you have pressed the escape key. Because the oBody variable is being created within that loop, it will only have a value if it has been assigned a value by the Pick function. If it has not been assigned a value, due to you not picking something, then it 'Is Nothing', so then it obeys the 'Exit Sub' code, which will exit the Sub routine. If you have not included Sub Main or End Sub within your rule, those are implied for you in the background, so Exit Sub is essentially exiting the whole rule, just like if you had used 'Return' instead of 'Exit Sub'. If you have more code that needs to run after that loop, then you need to replace "Exit Sub" with something like "Exit While". Calling 'Exit While' will cause it to exit that loop, and move on to whatever other code may be beyond that loop.
PS. Also, even though I hinted at this in post, I just wanted to reiterate that if you are declaring the variable within the loop, that variable will not be recognized outside of that loop. If you want to use that variable, and any value assigned to it outside of that loop, you will need to declare that variable before the loop, then just set its value within the loop. But keep in mind that if you use the loop more than once, it other times it will just be replacing the variable's value, not adding multiple values to it. If you want to select multiple SurfaceBodies, you will need to create something like an ObjectCollection, or New List(Of SurfaceBody), or something similar before the loop, then add each selection to that collection object within the loop, so that the collection will retain its values after the loop has exited.
Wesley Crihfield

(Not an Autodesk Employee)