首页->技巧->窗口->详细内容
how to get multiple filenames back from the CommonDialog Control, parse the response and display each of the files.
This code uses the VB6 Split function, but if you want to use this code in VB5 you can simply write your own routine to parse the string of files returned from the CommonDialog control.
To use this add the CommonDialog control to your form and call it CommonDialog1, also add a CommandButton to your form and call it Command1. Paste in this code and run the project. When you click on the CommandButton and select multiple files from the CommonDialog control you should get each one repeated to you in a MessageBox.
Private Sub Command1_Click() Dim lsFiles() As String Dim i As Long CommonDialog1.Filter = "All Files|*.*" CommonDialog1.Flags = cdlOFNAllowMultiselect CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then lsFiles = Split(CommonDialog1.FileName, Chr(32)) For i = LBound(lsFiles) To UBound(lsFiles) MsgBox lsFiles(i) Next End If End Sub 返回