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.

Add 2 Command Button (named Command1 and Command2)
Add 1 Label (named Label1)
Add 1 Timer Control. Set the Timer Interval property to 1


VB Code:
  1. Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As _
  2. Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As _
  3. Long) As Long
  4.  
  5. Private Sub Command1_Click()
  6.     MsgBox "The Timer STOPS!"
  7. End Sub
  8.  
  9. Private Sub Command2_Click()
  10.     MessageBox Me.hwnd, "Notice the timer does not stop!", "API Call", _
  11. vbOKOnly + vbExclamation
  12. End Sub
  13.  
  14. Private Sub Timer1_Timer()
  15.     Label1.Caption = Time
  16. End Sub