At the load of a form I need to fill some data, but in order to do it correctly the program must wait a sec or two.

So I decided to use the typical Timer sample:

VB Code:
  1. Dim dTimer As Double
  2.             dTimer = Timer
  3.             waitTime = 1
  4.             Do While Timer < dTimer + waitTime
  5.                 DoEvents
  6.             Loop

Now the problem is that if I close the program while the program's still inside the Do While the form opens again and gives an error. Any help? Thanks in advance.