打开多个文件时,返回的是一个长字符串,包括路径文件名,中间用空格隔开,如何得到路径,和每个文件名

解决方案 »

  1.   

    Private Sub Command1_Click() 
      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_ALLOWMUL- SELECT 
      CommonDialog1.Action = 1 
      CommonDialog1.filename = CommonDi g1. filename & Chr(3 2) 
      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 
      Text 2.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