Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed with Progressbar and file search.

Status
Not open for further replies.

RonQA

Technical User
Jun 24, 2007
61
US
I would like to be able to add a progressbar to this code as it searches, but all my attempts results in the bar being updated at the end of the search instead of during.

For Each foundfile As String In My.Computer.FileSystem.GetFiles _
(PathDrawings, FileIO.SearchOption.SearchAllSubDirectories, TextBox1.Text & "*.pdf")

ListBox1.Items.Add(foundfile)

Does anyone have any ideas?

Thanks,
 
You either have to look into doing Thread/Delegates or add Application.DoEvents after incrementing your progress bar. The best method is Thread/Delegate the easiest method is Application.DoEvents.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
A third alternative would be to employ a BackgroundWorker. It's basically threading but a little easier to code.
 
I always forget about a BW as I never totally understood it before. Likely I just need to revisit it now that I have more experience with threading.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top