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
Application.DoEvents()

‘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
ToughDev

ToughDev

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