editbox clear command

m working on application where i put a clear botton i want that whenver i click on it it would clear all the fields data so i used this code in pushbotton clear(edit3,edit4,text1); but its not working so how to do this would you please tell me........

Answers (1)

Jan
Jan on 22 Apr 2012
"It is not working" does not contain enough details to find a valuable advice. Please post the code. The CLEAR command clears variables from the workspace, but not the contents of UICONTROLs. Perhaps you want to set the contents explcitly:
set([edit3, edit4, text1], 'String', '');

4 Comments

emmi rdx
emmi rdx on 22 Apr 2012
yes i want to clear the text in these field for new values but its not working.........
What error do you get?
Jan's solution is correct, provided you pass in the correct handles.
However, there is a possibility that some part of your code might have been written to assume that one of those handles always returns a cell array of strings rather than a string; in such a case you could use {''} instead of '' but better in such a case would be to use cellstr(get(HANDLE, 'string')) instead of just get(HANDLE, 'string')
You also might need a drawnow.
If she used GUIDE, you would have to do
set(handles.edit3, 'String', '');
because the tag (the name of the edit box control) is always preceded by handles.

Sign in to comment.

Categories

Asked:

on 22 Apr 2012

Community Treasure Hunt

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

Start Hunting!