In Visual Basic, if you make a call to the MsgBox function, all other background processes that you may have running (counters, timer events, etc) are stopped until the user acknowledges the Msgbox dialog box. This can be potentially devastating if you write an application that runs unattended.
To overcome this problem, you must use the Windows API call for the
MessageBox function. It looks and acts the same as the Visual Basic "msgbox"
function, but does not stop the background processes from running.
The
Code below show the difference between the two methods.
Press the first
button to display message box
with VB
MsgBox function, and the second button to display it via API.
Private Sub Command2_Click()
MessageBox Me.hwnd, "Notice the timer does
not stop!", "API Call", _
vbOKOnly + vbExclamation
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub