查看单个帖子
旧 2008-11-09, 12:35   #2
xiezhh
普通会员
 
注册日期: 2007-08-07
帖子: 64
声望力: 20
xiezhh 是一个将要出名的人
默认 回复: [求助]eidt text空输入问题,感谢帮助!

如下测试没有问题

fig = figure ;
set(fig,'units','normalized','position',[0.0381 0.0742 0.9277 0.8464],...
'menubar','none','name','成绩分析系统',...
'numbertitle','off','color',[0.925 0.914 0.847],'tag','cjfx');
panel0=uipanel(fig,'units','normalized','pos',[0.038 0.002 0.646 0.265],'title','请输入相关信息',...
'fontsize',12,'fontweight','bold');
panel0=uipanel(fig,'units','normalized','pos',[0.038 0.002 0.646 0.265],'title','请输入相关信息',...
'fontsize',12,'fontweight','bold');
uicontrol(panel0,'style','edit','units','normalized','pos',[0.55 0.74 0.15 0.22],...
'fontsize',14,'fontunits','normalized','tag','edit1','backgroundcolor',[1 1 1]);
h=findobj(gcf,'tag','edit1');

user_entry=str2double(get(h,'String'));
if isempty(user_entry)
user_entry=0;
else
a=user_entry;
end

需要注意的是,若编辑框不输任何字符,user_entry=str2double(get(h,'String'));返回的user_entry为NaN,不为空。
xiezhh 当前离线   回复时引用此帖