Yes. However, calling DoEvents (or your api_doevents) every loop iteration is probably overkill. The more DoEvents that get executed, less accurate your WaitMs function will be, because other code will be running too. Play with iCount and maybe increase it, by 10's or 100's, or even decrease to see any differences