Z = 1 For I = 1 To Len(CommonDialog1.filename) I = InStr(Z, CommonDialog1.filename, Chr(32)) If I = 0 Then Exit For ReDim Preserve FileNames(Y) FileNames(Y) = Mid(CommonDialog1.filename, Z, I - Z) Z = I + 1 Y = Y + 1 Next
If Y = 1 Then Text1.Text = FileNames(0) Else Text2.Text = "" For I = 0 To Y - 1 If I = 0 Then Text1.Text = FileNames(I) Else Text2.Text = Text2.Text & UCase(FileNames(I)) & Chr$(13) & Chr$(10) End If Next End If End Sub
Private Sub Command1_Click() With CommonDialog1 .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer .Filter = "*.*" .ShowOpen End With End SubFlags 属性(“打开”、“另存为”对话框)cdlOFNAllowMultiselect &H200 它指定文件名列表框允许多重选择。 运行时,通过按 SHIFT 键以及使用 UP ARROW 和 DOWN ARROW 键可选择多个文件。作完此操作后,FileName 属性就返回一个包含全部所选文件名的字符串。串中各文件名用空格隔开。cdlOFNExplorer &H80000 它使用类似资源管理器的打开一个文件的对话框模板。适用于 Windows 95 和 Windows NT 4.0。
Dim I As Integer
Dim Y As Integer
Dim Z As Integer
Dim FileNames$()
Const OFN_ALLOWMULTISELECT = &H200&
CommonDialog1.filename = ""
CommonDialog1.Filter = "All Files|*.*"
CommonDialog1.Flags = OFN_ALLOWMULTISELECT
CommonDialog1.Action = 1
CommonDialog1.filename = CommonDialog1.filename & Chr(32)
Z = 1
For I = 1 To Len(CommonDialog1.filename)
I = InStr(Z, CommonDialog1.filename, Chr(32))
If I = 0 Then Exit For
ReDim Preserve FileNames(Y)
FileNames(Y) = Mid(CommonDialog1.filename, Z, I - Z)
Z = I + 1
Y = Y + 1
Next
If Y = 1 Then
Text1.Text = FileNames(0)
Else
Text2.Text = ""
For I = 0 To Y - 1
If I = 0 Then
Text1.Text = FileNames(I)
Else
Text2.Text = Text2.Text & UCase(FileNames(I))
& Chr$(13) & Chr$(10)
End If
Next
End If
End Sub
With CommonDialog1
.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
.Filter = "*.*"
.ShowOpen
End With
End SubFlags 属性(“打开”、“另存为”对话框)cdlOFNAllowMultiselect &H200 它指定文件名列表框允许多重选择。
运行时,通过按 SHIFT 键以及使用 UP ARROW 和 DOWN ARROW 键可选择多个文件。作完此操作后,FileName 属性就返回一个包含全部所选文件名的字符串。串中各文件名用空格隔开。cdlOFNExplorer &H80000 它使用类似资源管理器的打开一个文件的对话框模板。适用于 Windows 95 和 Windows NT 4.0。