'添加 Drive1 Dir1 File1 Command1 List1Option Explicit 'File1.MultiSelect =2 ' 你在属性窗里面设Dim i%, dirpath$ Private Sub Dir1_Change() File1.Path = Dir1.Path End SubPrivate Sub Drive1_Change() Dir1.Path = Drive1.Drive End SubPrivate Sub Command1_Click() dirpath = IIf(Right(Dir1.Path, 1) = "\", Dir1.Path, Dir1.Path & "\") If File1.ListCount > 0 Then List1.Clear For i = 0 To File1.ListCount - 1 If File1.Selected(i) Then List1.AddItem dirpath & File1.List(i) Next i End If End Sub
'添加 Drive1 Dir1 File1 Command1 'File1.MultiSelect =2 '你在属性窗里面设Option Explicit Dim i%, dirpath$, Selstr$(), trec% Private Sub Dir1_Change() File1.Path = Dir1.Path End SubPrivate Sub Drive1_Change() Dir1.Path = Drive1.Drive End SubPrivate Sub Command1_Click() dirpath = IIf(Right(Dir1.Path, 1) = "\", Dir1.Path, Dir1.Path & "\") If File1.ListCount > 0 Then ReDim Preserve Selstr$(0) trec = 0: Selstr(0) = "" For i = 0 To File1.ListCount - 1 If File1.Selected(i) Then ReDim Preserve Selstr$(trec) Selstr(trec) = dirpath & File1.List(i) trec = trec + 1 End If Next i '************ 看看上面的数组变量 If Selstr(0) <> "" Then '检测数组中是否有选中内容 Me.Cls For i = 0 To trec - 1 Print Selstr(i) Next i MsgBox "共选中 " & CStr(trec) & " 笔" Else MsgBox "无选中内容" End If End If End Sub
'File1.MultiSelect =2 ' 你在属性窗里面设Dim i%, dirpath$
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End SubPrivate Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End SubPrivate Sub Command1_Click()
dirpath = IIf(Right(Dir1.Path, 1) = "\", Dir1.Path, Dir1.Path & "\")
If File1.ListCount > 0 Then
List1.Clear
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then List1.AddItem dirpath & File1.List(i)
Next i
End If
End Sub
'File1.MultiSelect =2 '你在属性窗里面设Option Explicit
Dim i%, dirpath$, Selstr$(), trec%
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End SubPrivate Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End SubPrivate Sub Command1_Click()
dirpath = IIf(Right(Dir1.Path, 1) = "\", Dir1.Path, Dir1.Path & "\")
If File1.ListCount > 0 Then
ReDim Preserve Selstr$(0)
trec = 0: Selstr(0) = ""
For i = 0 To File1.ListCount - 1
If File1.Selected(i) Then
ReDim Preserve Selstr$(trec)
Selstr(trec) = dirpath & File1.List(i)
trec = trec + 1
End If
Next i
'************ 看看上面的数组变量
If Selstr(0) <> "" Then '检测数组中是否有选中内容
Me.Cls
For i = 0 To trec - 1
Print Selstr(i)
Next i
MsgBox "共选中 " & CStr(trec) & " 笔"
Else
MsgBox "无选中内容"
End If
End If
End Sub