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 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
PT
on 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
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!