DoEvents フロー制御

DoEvents関数はある処理の実行中に発生したキー入力や、マウスのクリックなどのイベントに対して正常に応答できるように、実行中の処理に割り込みをかけるときに使用します。
しかし32 ビット版のVBでは、コードの中で "イベント待ち状態" を実現するためには、DoEvents を使用するよりも、Sleep API関数を使用するほうがより適切、と ヘルプにもありあます。
Delphiで、Sleep APIを使用するには以下のように記述すればOKです。単位はミリ秒です。

sleep(1000);

また、Sleepでは無くイベントの割り込みを起こしたい場合は Applicationオブジェクトの ProcessMessages メソッドを使用します。

■ Application.ProcessMessagesの使用例
  var
    blnStop : boolean; {カウントストップフラグ}

  //初期処理
  procedure TForm1.FormCreate(Sender: TObject);
  begin
    blnStop :=  False;
  end;

  //カウント開始
  procedure TForm1.Button1Click(Sender: TObject);
  var
    intCount  : integer;
  begin
    intCount  :=  0;
    while  Not  blnStop  do  begin
      inc(intCount);
      Label1.Caption  :=  IntToStr(intCount);
      Application.ProcessMessages;
    end;
  end;

  //カウント停止
  procedure TForm1.Button2Click(Sender: TObject);
  begin
    blnStop :=  True;
  end;