How to check if OK is pressed or not in a msgbox
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I would like to know how I can check if OK is pressed or not in a msgbox
I tried using strcmp but there seems to be a problem.
Button = msgbox(sprintf('The TryNumber is %d.\nClick OK to Stop',TryNumber));
if strcmp(Button , 'OK')
#do_something
else
#do_something
end
Can somebody help me resolve this issue. Thank you.
2 commentaires
Réponses (1)
Image Analyst
le 12 Juin 2018
Try using questdlg() instead:
promptMessage = sprintf('Do you want to Continue processing,\nor Quit processing?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
return;
end
2 commentaires
Image Analyst
le 12 Juin 2018
You could add a third option for "non-stop" where if they click that, you set a flag where you basically don't ask them anymore.
Voir également
Catégories
En savoir plus sur Dialog Boxes dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!