一、菜单
二、工具栏
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