声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2303|回复: 6

[编程技巧] 如何清除文本框的内容??

[复制链接]
发表于 2006-11-12 19:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
求助!!
编一个M 文件 有一个可编辑的文本框
想设一个按钮可以清除已经输入文本框的内容!??
回复
分享到:

使用道具 举报

发表于 2006-11-12 19:32 | 显示全部楼层
假设按钮的tag为pushbutton1,编辑框的tag为edit1
则按钮的回电函数:
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.edit1,'string',' ');

可实现清除已经输入文本框的内容。
 楼主| 发表于 2006-11-12 19:36 | 显示全部楼层
不行啊 我试了 报错!!
 楼主| 发表于 2006-11-12 19:38 | 显示全部楼层
set(gcf,'position',[100,200,650,450]);
set(gcf,'menubar','none','name','sample','numbertitle','off');
hdraw=uimenu(gcf,'Label','&draw');
hmeshg=uimenu(hdraw,'Label','meshgrid','Call',...
    ['x=0:0.1:2*pi;','[x,y]=meshgrid(x);','plot(x,y,"*")','grid on;',...
    'view(3);']);
hmesh=uimenu(hdraw,'Label','mesh','Call','mesh(peaks);');
hsurf=uimenu(hdraw,'Label','surf','Call','surf(peaks);');
hcolormap=uimenu(gcf,'Label','&colormap');
hcool=uimenu(hcolormap,'Label','&cool','Call','colormap(cool);');
hhot=uimenu(hcolormap,'Label','&hot','Call','colormap(hot);');
hdefault=uimenu(hcolormap,'Label','&default','Call',...
    'colormap(jet);');
uimenu(gcf,'Label','&exit','Call','close(gcf)');
hfaceted=uicontrol(gcf,'style','push','string','faceted','call',...
    'shading faceted;','position',[500,300,80,34]);
hfalt=uicontrol(gcf,'style','push','string','falt','call',...
    'shading flat;','position',[500,250,80,34]);
uicontrol(gcf,'style','push','string','interp','call',...
    'shading interp;','position',[500,200,80,34]);
hxd=uicontrol(gcf,'style','edit','position',[510,140,30,30]);
hyd=uicontrol(gcf,'style','edit','position',[570,140,30,30]);
view=['x=str2num(get(hxd,"string"));','y=str2num(get(hyd,"string"));',...
    'view(x,y);'];
uicontrol(gcf,'style','text','string','x','position',[485,145,20,20]);
uicontrol(gcf,'style','text','string','y','position',[545,145,20,20]);
hview=uicontrol(gcf,'style','push','string','view','position',[500,100,80,30],...
   'call',view);
hedit=uicontrol(gcf,'style','edit','position',[40,45,420,30]);
hok=uicontrol(gcf,'style','push','string','OK','position',[488,47,45,25],...
    'call',['t=get(hedit,"string";)','eval(t);']);
hclear=uicontrol(gcf,'style','push','string','clear','position',[555,47,45,25],...
'call','set(hedit,"string"," ");');

我编的的 各位大大看一下
发表于 2006-11-12 20:48 | 显示全部楼层
把你里面的 "(双引号)  全部给改成 ''  (两个单引号)
再拿去试试,差不多就行了吧!你的错误应该是在这儿的
发表于 2006-11-12 20:50 | 显示全部楼层
我的代码是在GUI工具下的m文件实现,并且
通过matlab 6.5的运行了,
 楼主| 发表于 2006-11-12 20:59 | 显示全部楼层
呵呵 谢谢 问题解决了谢谢
今天又学了点!!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-25 01:18 , Processed in 0.060969 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表