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 (최근 30일)
이전 댓글 표시
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
채택된 답변
PT
2013년 3월 27일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!