GUI Edit Text

2 views (last 30 days)
dinh tai
dinh tai on 11 Apr 2012
How to make string in edit_text1 from edit_text2 exp : In edit_text1 : 123456789 In edit_text2 : 123
  3 Comments
dinh tai
dinh tai on 11 Apr 2012
i want to get text2 one character from callback of text1 (
exp :
text1 : 123456789
text2 : 3
I wrote :
A=get(handles.edit1,'string');
set(handles.edit2,'string',A(1));
But it not worked!
Image Analyst
Image Analyst on 11 Apr 2012
Yeah, it wouldn't if your "tag" for the edit text control was edit_text1 like you said first.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 11 Apr 2012
% Get the string in the control called handles.edit_text1.
string1 = get(handles.edit_text1, 'String');
% Extract just a portion of it.
string2 = string1(1:3); % Or whatever you want to start and stop at.
% Send that string2 to the control called handles.edit_text2.
set(handles.edit_text2, 'String', string2);
drawnow; % If needed, like you're in an intensive loop.
  3 Comments
Image Analyst
Image Analyst on 11 Apr 2012
Then show YOUR code because you did not run any of our code. You probably misspelled something, or are using different names for your controls and didn't modify our code to reflect that, or somehow otherwise changed things. Why don't you tell us the actual error message? Copy and paste all of the red error text that you see in the command window.
dinh tai
dinh tai on 11 Apr 2012
I used the wrong name of Text1 and Text2.
Now everything is okay. Thank you very much.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 11 Apr 2012
set(handles.edit_text1, 'String', get(handles.edit_text2, 'String'))
  1 Comment
dinh tai
dinh tai on 11 Apr 2012
if i want length of string in text2 shorter string in text1.
How to make it?

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!