Azzera filtri
Azzera filtri

How to pull edit box string from uicontrol

14 visualizzazioni (ultimi 30 giorni)
Meaghan
Meaghan il 30 Mag 2013
Risposto: LO il 31 Mag 2019
Hi all,
Having trouble getting the program to recognize the text entered by the user. It reads as empty because that is what is first called. Tried using callback, but it gets messy when the uicontrol needs to be defined in the callback value and the callback value needs to be defined in the uicontrol.
Here's what I have:
[~, ~, read] = xlsread('C:\Users\mpaulosk\Desktop\Folder\prelim_gui.xls','Sheet1');
paramtext = vertcat(read(2,1))
descriptext = vertcat(read(2,2))
descripedit = vertcat(read(3,2));
paramedit = vertcat(read(8,1));
paramtext = uicontrol('Style', 'text', 'String', descriptext,...
'Position', [100 350 100 40]);
test = uicontrol ('Style', 'text', 'String', descripedit,...
'Position', [100 295 100 40]);
paramedit = uicontrol('Style', 'edit', ...
'Position', [200 375 100 20]);
edittest = uicontrol('Style', 'edit', ...
'Position', [200 320 100 20], 'Callback','helppppppp')
I can explain further if not clear. Thanks!

Risposta accettata

Walter Roberson
Walter Roberson il 30 Mag 2013
edittest = uicontrol('Style', 'edit', ...
'Position', [200 320 100 20], 'Callback', @helppppppp);
Then
function helppppppp(hObject, event)
current_string = get(hObject, 'String');
Now that you have it, what do you want to do with it?
  1 Commento
Meaghan
Meaghan il 30 Mag 2013
Thank you!! I got it to work, now I'm writing it to another excel file, but I'm better with that.
Thanks again!

Accedi per commentare.

Più risposte (2)

Andrew Lanman
Andrew Lanman il 31 Ago 2018
@Walter Roberson Thank you, been looking for a solution to this issue for over a week now.

LO
LO il 31 Mag 2019
as an alternative, instead of using an external function
you could type
edittest = uicontrol('Style', 'edit', 'Position', [200 320 100 20], 'Callback', 'val=ea.String;');
with the edited text stored in "val". If you want to save the string as number just use val=str2num(ea.String).

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by