单选题 VB
题号 #485200

在窗体上面一个名称为CommonDialonl的通用对话框,一个名为 Command1的命令按钮。要求单击命令按钮时,打开一个保存文件的通用对话框。该窗口的标题为“SaVe”,缺省文件名为“saV.Fil。”,在“文件类型”栏中显示m.txt。则能够满足上述要求的程序是(  )
A.Private Sub Command l_Click0
CommonDialog 1.FileName=“SaveFile”
CommonDialog 1.Filter=“All Files|*.*|(*.txt)|*.txt (*.doC.|*.doc”
CommonDialog 1.Filterlndex=2
CommonDialog 1.DialogTitle=“Save”
CommonDialog 1.Action=2
B.Private Sub Command1_Click()
ColmmonDialog 1.FileName=“SaveFile”
CommonDialog 1.Filter=“All Files|*.*|(*.txt)|*.txt (*.doC.|*.doc”
CommonDialog 1.FilterIndex=1
CommonDialog 1.DialogTitle=“Save”
CommonDialog 1.Action=2
End Sub
C.Private Sub Command1_Click()
CommonDialog 1.FileName=“Save”
CommonDialog 1.Filter=“All Files|*.*|(*.txt)|*.txt (*.doC.|*.doc”
ConlmonDialog 1.Filterlndex=2
CommonDialog 1.DialogTitle=“SaveFile”
CommonDialog 1.Action=2
End Sub
D.Private Sub Command l_Click()
CoImmonDialog 1.FileName=“1SaveFile”
CommonDialog 1.Filter=“All Files|*.*|(*.txt)|*.txt (*.doC.|*.doc”
CommonDialog 1.Filterlndex=1
CommonDialog 1.DialogTitle=“Save”
CommonDialog 1.Action=1

进入在线模考

参考答案

A

答案解析

本题涉及到的通用对话框的属性较多,含义如下:
FileName:用来设置或返回要保存的文件的路径及文件名;本题中,该属性值应为“SaveFile”。
Filter:用来指定在对话框中显示的文件类型:
Filterlndex:用来指定默认的过滤器,其设置值为一整数。用Filter属性设置多个过滤器后,每个过滤器都有一个值,第一个过滤器的值为1,第二个过滤器的值为2……;本题中,该属性应为2:
DialogTitle:该属性用来设置对话框的标题;本题中,该属性值应为 “save”。
Action:该属性用来设置对话框的类型,对于“保存文件”对话框,该属性值为2。
综上所述,答案是A。

你可能感兴趣的试题

A.在程序运行时,通用对话框控件是不可见的
B.在同一个程序中,用不同的方法(如ShowOpen或ShowSave等)打开的通用对话框具有不同的作用
C.调用通用对话框控件的ShowOpen方法,可以直接打开在该通用对话框中指定的文件
D.调用通用对话框控件的ShowColor方法,可以打开颜色对话框
A.在同一窗体的菜单项中,不允许出现标题相同的菜单项
B.在菜单的标题栏中,“&”所引导的字母指明了访问该菜单项的访问键
C.程序运行过程中,可以重新设置菜单的Visible属性
D.弹出式菜单也在菜单编辑器中定义
找试题 · 找答案 · 找资料 在线模考