Don't let MsgBox interrupt some of the background processing jobs

Source: Internet
Author: User
Tags current time
Once you have called MsgBox, you are performing some of the Background processing jobs, such as counters or clocks ... And so on, will stop, until you respond to the MsgBox, everything will return to normal! Perhaps you do not want this, it may also cause some unnecessary mistakes!

To resolve this problem, you must use the Windows API to call the MessageBox Function, which uses the same methods, looks, and MsgBox results, but it does not interrupt some Background processing jobs!

In the following example, you add a Label, two CommandButton, and a Timer to the Form without changing any properties.

' Add the following declaration to the declaration area:

Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd as Long, ByVal Lptext as String, ByVal LP Caption as String, ByVal wtype as Long

' Add the following program code:

Private Sub Command1_Click ()
MsgBox "Timer's stopped!" ",", "VB message box"
End Sub

Private Sub Command2_Click ()
MessageBox Me.hwnd, "Note!" The timer's still running! "," API message box ", 64
End Sub

Private Sub Form_Load ()
Me.TimerInterval = 1000
Label1.Caption = "The current time is:" & Times
End Sub

Private Sub Timer1_timer ()
Label1.Caption = "The current time is:" & Times
End Sub



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.