MATLAB Answers

change text in a msgbox

72 views (last 30 days)
Michael on 28 Jul 2011
Commented: David Thoen on 8 Oct 2020 at 7:09
Hi everyone. I have a msgbox pop up with some information for the user, and I'd like to change the text at different points in the program so the user know whats going on. I could just close the msgbox and create a new one, but I thought it might be a little more elegant to just change the text. Is this possible?


Sign in to comment.

Accepted Answer

Oleg Komarov
Oleg Komarov on 28 Jul 2011
% Create a msgbox
h = msgbox('Hi');
% Change just the message
set(findobj(h,'Tag','MessageBox'),'String','How are you?')
% Make the pushbutton invisible
If the user closes the message box then you should create a new one.
On the other hand you can just create a modal msgbox that follows the first one and replaces it:
msgbox('How are you','modal');


Michael on 29 Jul 2011
Thanks Oleg! The first method you suggest is perfect.
Vyshakh Pv
Vyshakh Pv on 26 Feb 2020
How to change the text in title bar of the same message box?
David Thoen
David Thoen on 8 Oct 2020 at 7:09
please check 'doc msgbox' to find out more about title and icon.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!