how to make after fill in the second edit text gui then the process will proceed?

hi all, in my GUI, i have two edit text box that will require the user to fill in the model number and serial number. how i want to do it if only both of the edit text box is filled, then the process will proceed.if either one is not filled, a pop up message will ask the user to fill in.
thank you.

9 comentarios

Use get to obtain the String properties of both edit boxes, and use isempty to find out if they are filled.
content_str = get(handles.ModelNum,'String');
t_string = get(handles.SerialNum,'String');
if isempty(content_str)
errordlg('Please enter Model Number');
else if isempty(t_string)
errordlg('Please enter Serial Number');
end
end
I do it like the above. but it gives me error.
@NUR SHOLIHAH RAMLEE: Whenever you mention in the forum, that you get an error, post a copy of the complete message. It is easier to fix an error than to guess, what the error is.
Please use the {}Code button to properly layout your code so it is readable and can be copy-pasted to Matlab:
content_str = get(handles.ModelNum,'String');
t_string = get(handles.SerialNum,'String');
if isempty(content_str)
errordlg('Please enter Model Number');
end
if isempty(t_string)
errordlg('Please enter Serial Number');
end
What error does this code give you?
from the code above, after I run it, when I didn't fill in the model number, the error dialog to enter the model number popped out and no further process can be proceed. but after I fill in the model number and not the serial number, the process is still proceed. I want after both the edit text box is filled then the it will proceed to further process. how am I going to do that? thank you very much.
Apparently the string was not empty. Did that field contain spaces? You could try to wrap it in strtrim to remove whitespace.
from this code, it only popped out the errordlg if the model number is not scanned. if only the model number has been entered, the getsnapshot process runs neglecting the serial number which is not scanned.
From what you have shown, there is no reason why this code should not detect an empty field. So again: are you sure the field is really empty and does not contain any whitespace characters?
okay I have found the problem. it is that there is whitespace char in the guide .fig. thank youuuu very much!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Etiquetas

Preguntada:

el 18 de Mayo de 2018

Comentada:

el 22 de Mayo de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by