Using an if clouse, and based on a generated code ie User ID displayed in a textbox, how can i link the ID to a user name of choice by displaying the name in a txt box
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My GUI has two text boxes, User ID and User name. The user ID is automatically generated by an OCR engine i created. I want to extract the user id and use the IF clause to display a corresponding User name on the user name text box e.g if the user id generated is UAK008 then the user name is 'somebody' of choice upon pressing a push button.
0 commentaires
Réponse acceptée
PT
le 27 Mar 2013
Let's assume the following: The tag for the pushbutton is "update". The tag for the User ID editbox is "userid". The tag for the User name text box is "username".
Then in the callback function for update:
function update_Callback (hObject, eventdata, handles)
uid = get(handles.userid, 'String');
lookupTable = {
'UAK001' 'Joe'
'UAK002' 'Joel'
'UAK003' 'John'
'UAK004' 'Bob'
};
uname = '';
for i = 1:size(lookupTable,1)
if strcmp(lookupTable(i,1), uid)
uname = lookupTable(i,2);
break;
end
end
if ~isempty(uname)
set(handles.username, 'String', uname);
else
set(handles.username, 'String', 'Username not found!');
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!