How to get data from edit text box in GUI with a push button
Afficher commentaires plus anciens
Hi,
I am building a GUI with an edit text box and a puch button, and I want to save the data (which is written by the user) from the edit box to a variable when the button is pushed. So I was using this code, but I got the error of:
Attempt to reference field of non-structure array.
Error in untitled>button_send_Callback (line 105) data = get(handles.datatosend, 'String');
The code: global data; data = get(handles.datatosend, 'String');
I have no idea what can be the problem. Thank you for helping.
4 commentaires
Adam
le 3 Avr 2017
You've somehow messed up the handles structure so that it is no longer a struct. It's impossible to say how or where though without seeing the rest of your code.
The fact that you are using a global variable for data doesn't bode well though if you are using them in many other places too.
Geoff Hayes
le 3 Avr 2017
Bence - how are you launching your GUI? i.e. from the command line, the run button in the GUI or m-file editor, or are you opening the *.fig file (which is incorrect).
Bence Salanki
le 3 Avr 2017
Bence Salanki
le 3 Avr 2017
Réponses (1)
Geoff Hayes
le 4 Avr 2017
0 votes
GUIDE-created GUIs can be launched from the GUI editor, the m-file editor, or from the command line by invoking the name of the GUI. Opening the figure (the *.fig) file just opens the figure and it does not perform any of the initializations that are necessary/needed for using the GUI.
Catégories
En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!