Application.DoEvents and MessageBox

0.00 avg. rating (0% score) - 0 votes

If the user clicks ‘Yes’, the following will close the messagebox first before doing any other thing.

Private Sub TestMsgBox()
If MessageBox.Show(“Do Work?”, “Confirm?”) = Windows.Forms.DialogResult.Yes Then
‘this close the MessageBox first

‘start to do work
End If
End Sub

Without the call to Application.DoEvents (), the messagebox will still be visible after the user clicks Yes; it will only be closed after the Sub has finished.

An alternative is to do the work in a separate thread.

0.00 avg. rating (0% score) - 0 votes


A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>