Once again I "forgot" to add some code in order to get some help from you guys.
Private Sub UserForm_Initialize()
sn = Filter(Split(CreateObject("wscript.shell").Exec("cmd /c dir H:\PDF\*.pdf H:\DXF\*.dxf H:\STEP\*.stp H:\autocad\*.dwg /b /s").StdOut.ReadAll, vbCrLf), ".")
LB_001.List = Filter(sn, ".pdf")
LB_002.List = Filter(sn, ".dxf")
LB_003.List = Filter(sn, ".stp")
LB_004.List = Filter(sn, ".DWG")
UserForm1.Show
TextBox4.SetFocus
End Sub
So... the LB_001 now contains a lot of stuff
I'd like to isolate (only show) the files by typing a string in textbox4.
This search should be applied to LB_001, LB_002, LB_003 and LB_004, but I don't like to use the .removeItem-function, as I would like to be able to search some other file afterwards without running the DIR again,
sn = Filter(Split(CreateObject("wscript.shell").Exec("cmd /c dir H:\PDF\*.pdf H:\DXF\*.dxf H:\STEP\*.stp H:\autocad\*.dwg /b /s").StdOut.ReadAll, vbCrLf), ".")
My attempts;
Private Sub TextBox4_Change()
On Error Resume Next
'LB_001 = TextBox4.Text
'a = Len("*" & (Me.TextBox4.Text) & "*")
a = Len(Me.TextBox4.Text)
If Left(UserForm1.LB_001.Value, a) = UserForm1.Me.TextBox4.Text Then
With Me.LB_001
.AddItem Me.LB_001.List
End With
End If
End Sub
But, couldn't make it work.
Second attempt;
I had an idea to not use the removeitem, but show searchstring result in Listbox8 by typing ... then nothing had to be removed from LB_001(or 2, 3 and 4).
Then I should just hide the LB_001 to 4 an only show Listbox8, 9, 10 and listbox11 (showing PDF, DXF, STP and DWG's)!
Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
For i = LB_001.ListCount - 1 To 0 Step -1
'If InStr(1, LB_001.List(i), TextBox4) = 0 Then LB_001.RemoveItem (i)
If InStr(1, LB_001.List(i), TextBox4) = 0 Then ListBox8.AddItem (i)
'If LB_001.List(i) = TextBox4 Then ListBox8.AddItem (i)
Next i
End Sub
But the main goal was; as by typing in TextBox4 the result shows by reducing the amount of files in LB_001, 2, 3 and 4.
But as any of you can see; any help is appreciated!