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!