Reading data from text box
古いコメントを表示
I am simply trying to get user inputted data from a text box and read that data in a push button. Shouldn't it be as simple as a get(handles.DisplayNumber,'String'); function in the push button?
function DisplayNumber_CreateFcn(hObject, eventdata, handles) %text box
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Lookup.
function Lookup_Callback(hObject, eventdata, handles) %Push button
N = get(handles.DisplayNumber,'String');
3 件のコメント
Naz
2011 年 12 月 19 日
Yes.
Muhammad
2013 年 8 月 1 日
This is a very stupid answer to a question to reading an editbox. no where it is mentioned how editbox data is to be retrieved. He is talking about background color and everything and not the main thing that is required.
No, Muhammad, I do not agree. The answer, independent of which answer you actually mean, is neither stupid nor very stupid. Naz's answer solves the problem exhaustively and Steven has accepted it as a solution.
It would be polite if you do not post harsh opinions about the quality of other answers, but offer better solutions, if you think you know one. Thanks.
採用された回答
その他の回答 (1 件)
Eric Keller
2011 年 12 月 19 日
0 投票
don't you have to load the "handles" data? I don't use that functionality, but that's my understanding of how it works
3 件のコメント
Steven
2011 年 12 月 19 日
Eric Keller
2011 年 12 月 19 日
I see I'm wrong from the code sample. I always just debug/set a setpoint and see what the handles are. You are dereferencing the handles structure incorrectly somehow, only your debugger knows for sure. It will become obvious when you do this.
Walter Roberson
2011 年 12 月 19 日
I can tell from the code that Steven is using GUIDE; GUIDE callbacks automatically pass the handles structure in.
カテゴリ
ヘルプ センター および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!