⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 打开多个文件的例子(33KB)19fileinfo1.zip取得文件信息(4KB)20文件操作相关.zip常用的4个文件函数:检查文件是否存在; 分离文件路径等(2KB)21winpe.zip分析PE
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "用CommonDialog打开多个文件"
   ClientHeight    =   2772
   ClientLeft      =   1512
   ClientTop       =   2280
   ClientWidth     =   5676
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   2772
   ScaleWidth      =   5676
   Begin VB.CommandButton Command2 
      Caption         =   "退    出"
      Height          =   324
      Left            =   3432
      TabIndex        =   3
      Top             =   2352
      Width           =   1428
   End
   Begin VB.CommandButton Command1 
      Caption         =   "选择文件"
      Height          =   324
      Left            =   792
      TabIndex        =   0
      Top             =   2352
      Width           =   1428
   End
   Begin VB.ListBox List1 
      Height          =   1848
      Left            =   144
      TabIndex        =   1
      Top             =   360
      Width           =   5340
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   2016
      Top             =   0
      _ExtentX        =   677
      _ExtentY        =   677
      _Version        =   327681
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "选择的文件:"
      Height          =   180
      Left            =   144
      TabIndex        =   2
      Top             =   72
      Width           =   1080
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
    
    Dim DlgInfo As DlgFileInfo
    Dim I As Integer
    
    On Error GoTo ErrHandle
    
    '清除List1中的项
    List1.Clear
    
    '选择文件
    With CommonDialog1
        .CancelError = True
        .MaxFileSize = 32767 '被打开的文件名尺寸设置为最大,即32K
        .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks
        .DialogTitle = "选择文件"
        .Filter = "所有类型的文件(*.*)|*.*"
        .ShowOpen
        DlgInfo = GetDlgSelectFileInfo(.filename)
        .filename = ""      '在打开了*.pif文件后须将Filename属性置空,
                            '否则当选取多个*.pif文件后,当前路径会改变
    End With
    
    For I = 1 To DlgInfo.iCount
        List1.AddItem DlgInfo.sPath & DlgInfo.sFile(I)
    Next I
    
    Exit Sub

ErrHandle:
    ' 按了“取消”按钮

End Sub



Private Sub Command2_Click()
    End
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -