- ボタンの無効化
しかし、ボタンクリック時の処理に「非同期処理」が入ってくると厄介です。例えば、クイズゲームのプログラムで
- ボタンをクリックした時に「ピンポーン」と音を鳴らして正誤判定をする
- Doeventの呼び出しが必須
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub CommandButton1_Click() | |
CommandButton1.Enabled = False | |
Debug.Print Now() & "click" | |
'なんらかの処理 | |
'サウンドファイル再生などの非同期処理 | |
Application.Wait [Now()+”00:00:02.0”] | |
DoEvents 'Enabled=Trueの直前に書くこと | |
CommandButton1.Enabled = True | |
End Sub |