上面一个有误!
Private Function GetFiles(Filenames() as string,Filter AS String) as string
Dim I As Integer
Dim Y As Integer
Dim Z As Integer
Dim FileName as string
CommonDialog1.filename = ""
CommonDialog1.Filter = Filter
CommonDialog1.Flags = cdlOFNAllowMultiselect + cdlOFNExplorer + cdlOFNFileMustExist + cdlOFNHideReadOnly
Commondialog1.ShowOpen
filename=commondialog1.filename
if instr(filename,chr(0))=0 then '如果只选择了一个文件就返回这个文件名
getfiles=filename
exit function
end if
filenames=split(filename,chr(0)) 'filenames(0)内内容为路径名,filenames(1)为第一个文件名(不包含路径),filenames(2)为第二个文件名,……
getfiles=iif(right(filenames(0)),1) = "\" ,filenames(0),filenames(0) & "\") & filenames(1)'返回第一个文件名
End Function
Private Function GetFiles(Filenames() as string) as string
Dim I As Integer
Dim Y As Integer
Dim Z As Integer
Dim FileName as string
CommonDialog1.filename = ""
CommonDialog1.Filter = "All Files¦*.*"
CommonDialog1.Flags = &H200 + &H8
filename=commondialog1.filename
if instr(filename,chr(0))=0 then '如果只选择了一个文件就返回这个文件名
getfiles=filename
exit function
end if
filenames=split(filename,chr(0)) 'filenames(0)内内容为路径名,filenames(1)为第一个文件名(不包含路径),filenames(2)为第二个文件名,……
getfiles=iif(right(filenames(0)),1) = "\" ,filenames(0),filenames(0) & "\") & filenames(1)'返回第一个文件名
End Function
Specifies that the File Namelist box allows multiple selections.
The user can select more than one file atrun time by pressing the SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files. When this is done, the FileName property returns a string containing the names of all selected files. The names in the string are delimited by spaces.
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