'我本来一点不会,但是从网上信息研究后写出了这个,参考一下吧 Option Explicit Private Sub Command1_Click() Dim fs, f, fc, f1 Dim i As Integer Dim b As Boolean Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.getfolder(App.Path) Set fc = f.Files List2.Clear List3.Clear For i = 0 To List1.ListCount - 1 b = False For Each f1 In fc If Left(f1.Name, Len(List1.List(i))) = List1.List(i) Then List2.AddItem List1.List(i) b = True Exit For End If Next If Not b Then List3.AddItem List1.List(i) End If Next i End Sub Private Sub Form_Load() List1.AddItem "周星驰" List1.AddItem "刘德华" List1.AddItem "成龙" List1.AddItem "山口百惠" End Sub
dim sPath as string sPath=app.path & "\" For i = 0 To List1.ListCount - 1 if dir(sPath & "*" & list(i) & "*") <> "" then list2.additem list1.list(i) else list3.additem list1.list(i) end if Next
'按钮b Private Sub Command2_Click() Dim j As Integer List2.Clear List3.Clear For j = 0 To List1.ListCount - 1 If InStr(Text1.Text, List1.List(j)) > 0 Then List2.AddItem List1.List(j) Else List3.AddItem List1.List(j) End If Next j End Sub