Private Sub Command1_Click()
     Dim I As Integer
     Dim Y As Integer
     Dim Z As Integer
     Dim FileNames$()
     CommonDialog1.FileName = ""
     CommonDialog1.Filter = "All Files|*.*"
     CommonDialog1.Flags = cdlOFNAllowMultiselect + cdlOFNExplorer
     CommonDialog1.Action = 1
     CommonDialog1.FileName = CommonDialog1.FileName & Chr(0)
     Z = 1
     For I = 1 To Len(CommonDialog1.FileName)
     I = InStr(Z, CommonDialog1.FileName, Chr(0))
     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)
    List1.AddItem Text1.Text & "\" & UCase(FileNames(I))
     End If
     Next
     End If
End Sub

解决方案 »

  1.   

    对了,用Split函数可以把所以的文件名分开,但要注意的是,各个文件名间的分隔符不是空格,而是ASCII码为0的字符。可能这是为了区别长文件中的空格吧。sFileNameArray = Split(sFileName , Chr(0))sFilePath = sFileNameArray(0)If Right(sFilePath,1)<>"\" Then  sFilePath = sFilePath & "\"End IfFor i = 1 To UBound(sFileNameArray)  Open sFilePath & sFileNameArray(i) For Input As #1  ......Next i
      

  2.   

    dim FileStr AS string
    FileStr=Split(CommonDialog1.FileName)
    FOR I=0 TO Ubound(FileStr)
      Open FileStr(I) For Input As #1
      ....
    NEXT
      

  3.   

    dim FileStr AS string
    FileStr=Split(CommonDialog1.FileName)
    FOR I=0 TO Ubound(FileStr)
      Open FileStr(I) For Input As #1
      ....
    NEXT