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

最佳答案

this question中有一些示例代码。报价单:

在VB6中,添加组件:

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

  • 现在,在表单上,​​从工具箱中添加新的“通用对话框”控件。

    在代码中,您需要:
    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
    

    关于vb6 - 如何在VB 6中使用打开文件对话框?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1085436/

    10-12 03:40