【精品文档】vb多功能记事本代码【精品文档】vb多功能记事本代码
为程序添加这两个控件,openfiledialog的name属性为ofd,filter为rtf文件|*.rtf|所有文件|*.*,savefiledialog的name为sfd,filename为无标题,filter为rtf文件|*.rtf。dim bool as boolean=false
menunew的click事件:
if bool=true or trim(richtextbox.text)nothing then
'判断当前文件是否从磁盘打开,或新建的文件内容不为空
el...
【精品文档】vb多功能记事本代码
为程序添加这两个控件,openfiledialog的name属性为ofd,filter为rtf文件|*.rtf|所有文件|*.*,savefiledialog的name为sfd,filename为无标题,filter为rtf文件|*.rtf。dim bool as boolean=false
menunew的click事件:
if bool=true or trim(richtextbox.text)nothing then
'判断当前文件是否从磁盘打开,或新建的文件内容不为空
else
exit sub
end if
dim result as integer
result=msgbox("文档尚未保存,是否继续,",msgboxstyle.yesnocancel)
select case result
case 2 '按下cancel按钮
exit sub
case 6 '按下yes按钮
if bool=true then
richtextbox.savefile(ofd.filename) elseif sfd.showdialog=dialogresult.ok then
richtextbox.savefile(sfd.filename) else
exit sub
end if
end select
bool=false
richtextbox.clear()
menuopen的click事件:
try
if bool=true or trim(richtextbox.text)nothing then
dim result as integer
result=msgbox("文档尚未保存,是否继续,",msgboxstyle.yesnocancel)
select case result
case 2
exit sub
case 6
if bool=true then '判断是否从已存在的文件打开的还是新建的 richtextbox.savefile(ofd.filename) elseif sfd.showdialog=dialogresult.ok then '按路径保存文件 richtextbox.savefile(sfd.filename) '弹出对话框保存文件
else
exit sub
end if
end select
end if
ofd.restoredirectory=true '还原当前目录
if ofd.showdialog()=dialogresult.ok and ofd.filename"" then
richtextbox.loadfile(ofd.filename) '打开文件
bool=true
end if
catch ex as exception messagebox.show(ex.message) end try
本文档为【【精品文档】vb多功能记事本代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。