VB6.0(第九课)

一、菜单

二、工具栏
Toolbar:工程----部件----controls 6.0(SP6)

三、状态栏
StatusBar:工程----部件----controls 6.0(SP6)
在这里插入图片描述

Private sub timer1_timer()
  statusbar1.panels(1).text  =  format( date ,"YYYY-MM-DD")
  statusbar1.panels(2).text  =  format(now,"hh:mm")
end sub
if text1.text<> ""  then
   form2.statusBar1.panels(1).text = "当前用户为:" &  text1.text
   form2.show
   unload me
 else
     msgbox  "请输入用户名!" , vbcritical, "信息提示"
 end if 

四、对话框
1、inputbox
2、msgbox
3、公用对话框:打开、另存为、颜色、字体、打印、帮助
工程----部件----microsoft Common Dialog Controls 6.0(SP6)
在这里插入图片描述
commondialog控件的action属性或show方法都可调出所需的对话框。
在这里插入图片描述
(2)filename:用于设置“文件名”文本框中所显示的文件名,在程序执行时用户用鼠标选中某个文件,选择的文件的文件名被显示在“文件名”文本框中,用此文件名为filename属性赋值。filename属性将得到一个包含路径名和文件名的字符串。

(3)filetitle:返回或设置用户所要打开文件的文件名,不包括路径。

(4)Filter:过滤器
在这里插入图片描述
如:
打开对话框的使用:

Private sub command1_click()
 commondialog1.filter ="BMP图片(*.bmp) | JPG图片(*.jpg) | GIF图片(*.gif) | 所有文件(*.*)"
 commondialog1.action =1  '调用打开对话框
 text1.text =  commandialog1.filetitle  
 text2.text =  commandialog1.filename  
end sub

在这里插入图片描述
另外使用showopen 方法也可以打开“打开”对话框:

commanddialog1.showopen

另存为对话框的使用:

commandialog1.dialogtitle = "保存纯文本文件"
commandialog1.filter = "文本文件| *.txt"
commandialog1.initdir = "E:\"    '初始路径
commandialog1.action=2   
if commandialog1.filename<> ""  then
  open commandialog1.filename for output as  #1   '打开文件
  print  #1 ,text1.text           '输入文本
  close   #1              '关闭文件
 end if

在这里插入图片描述
另外使用showsave 方法也可以打开“另存为”对话框:

commandialog1.showsave

颜色对话框的使用

commandialog1.action =3
 text1.forecolor =commandialog1.color   '设置文本框的前景色
 end sub 

同样也可以使用showcolor方法调用“颜色”对话框:

commandialog1.showcolor

字体对话框的使用
在这里插入图片描述

commandialog1.flags =3          '设置flags的属性值
commandialog1.action=4         '调用字体对话框
if   commanddialog1.fontname<>""  then  
       text1.text.fontname=commandialog1.fontname        '为文本框的字体赋值
       text1.fontsize=commandialog1.fontsize
       text1.fontbold=commandialog1.fontbold
       text1.fontltalic=commandialog1.fontltalic
else
       msgbox  "有误"          
end if 

同样也可以使用showfont方法调用“颜色”对话框:

commandialog1.showfont

打印对话框

commandialog1.action=5     '调用打印对话框

同样也可以使用showprinter方法调用“颜色”对话框:

commandialog1.showprinter

帮助对话框

commandialog1.helpcommand  = cdlhelpcontents   '调用帮助属性
commandialog1.helpfile   =   "c:\windows\help\notepad.hlp"
commandialog1.showhelp
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值