请引用 Microsoft Common dialog Control 6.0 部件 ' 需要 text1 text2 list1 button1 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
' 需要 text1 text2 list1 button1
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