password.txt

来自「一个matlab密码输入界面的原代码」· 文本 代码 · 共 43 行

TXT
43
字号
function editPassword_Callback(hObject, eventdata, handles) 
% hObject    handle to editPassword (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 

% Hints: get(hObject,'String') returns contents of editPassword as text 
%        str2double(get(hObject,'String')) returns contents of editPassword as a double 

passChar = get(handles.editPassword,'UserData'); 
if strcmp(passChar,'5201314') 
   msgbox('OK! You can entern my heart now no3!'); 
else 
   msgbox('Sorry,we have no words together no4!'); 
end 



% --- Executes on key press over editPassword with no controls selected. 
function editPassword_KeyPressFcn(hObject, eventdata, handles) 
% hObject    handle to editPassword (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
currChar = get(gcf,'CurrentKey') 
switch currChar 
   case {'backspace','delete'}, 
       Char = []; 
       set(gcbo,'String',''); 
       drawnow; 
   case 'return', 
       passChar = get(gcbo,'UserData'); 
       if strcmp(passChar,'5201314') 
           msgbox('OK! You can entern my heart now no1!'); 
       else 
           msgbox('Sorry,we have no words together no2!'); 
       end 
       return 
   otherwise, 
       oldChar = get(gcbo,'UserData'); 
       Char = [oldChar,currChar]; 
       set(gcbo,'string',char('*'*ones(1,length(Char)))); 
end 
set(gcbo,'UserData',Char); 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?