如何在VB 6中使用打开文件对话框?

Gop*_*pal 8 vb6

VB 6新手

我想从目录或其他系统中选择一个文件.如何在VB 6中使用打开文件对话框?

需要VB 6代码帮助.

Ant*_*Ant 20

这个问题中有一些示例代码.引用:

在VB6中,添加组件:

  • 项目>组件
  • 在"控件"选项卡上,选择"Microsoft通用对话框控件6.0"(SP6)

现在在表单上,​​从工具箱中添加新的Common Dialog控件

在代码中,您需要:

CommonDialog1.Filter = "Apps (*.txt)|*.txt|All files (*.*)|*.*"
CommonDialog1.DefaultExt = "txt"
CommonDialog1.DialogTitle = "Select File"
CommonDialog1.ShowOpen

'The FileName property gives you the variable you need to use
MsgBox CommonDialog1.FileName
Run Code Online (Sandbox Code Playgroud)