To use thread in programming in vb6

Solution 1:

The only "legal" way to do multi-threading in VB6 is through ActiveX EXEs -- just use the thread per object option on the project properties dialog. Matt Curland has a good example how to convert your Standard EXE to a multi-threaded ActiveX EXE. Doing it this way allows VB6 debugger to works w/o crashes because in the IDE everything is executed on a single thread.

If you want to cut down the overhead of ActiveX EXE multi-threading then you have to use in-proc multi-threading which is not supported but still doable. Check Compact In-Process Multi-threading: A FolderWatcher with sample UI for a way to safely use CreateThread and to safely initialize VB6 run-time on the new thread (courtesy Matt Curland again).

You might want to check his Advanced Visual Basic 6 book for more details.

Solution 2:

You can use the CreateThread Win32 API but please keep in mind that the VB6 debugger cannot handle multiple threads.

Also, if you have loops of any kind, try slapping "DoEvents" somewhere in the loop. It will severely cut back on performance but your forms will be responsive.