Oh god, I'm going back decades (before C, much less ++

), so I can't offer specifics. In general, if you can't use an expression such as "Do while BooleanFlag = False", or something similar, you can simply set up an outer "If" loop:
Swapped = False
If Swapped = False
....your existing If loop logic...
Swapped = True (when the swap is made...this should terminate the outer loop)
Sorry I don't know C++, and my programming skills are rusty, but maybe this will get you thinking in the right direction...
edited: sorry, I lose my indentations on the looping logic...hope it's still clear as mud