You can leave out the Try... Except there ... since the MessageDlg is unlikely to fail

[pascal]
if MessageDlg('Press Yes or No', mtConfirmation, [MBYES, MBNO], 0) = MRYES then
Begin
ShowMessage('The user clicked on YES button.');
End
Else
Begin
ShowMessage('The user clicked the NO button.');
End;
[/pascal]


It might be that I misunderstood what you where trying to do, however I don't see the need for try...except in this scenario... If you want to jump from the loop if the user presses the yes / no button you could use the exit command...