Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting while msgbox is active 1

Status
Not open for further replies.

shaminda

Programmer
Jun 9, 2000
170
US
I have two counters that runs using a timer. So according to the timer Interval the counter goes up. I print an error message(using MsgBox) when the first counter reaches say 100. But until I close the message the second count won't count. How do I increment the second counter when the message box is stile active?




 
I don't think that's possible. You'll probably have to create a seperate form using vbModeless in the .Show statement for it to work.

--MiggyD
 
Keep Your Background Processes Running When Displaying Message Box

Author: Microsoft


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.



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

Module Code
Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As _
Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As _
Long) As Long

Form Code
Private Sub Command1_Click()
MsgBox "The Timer STOPS!"
End Sub

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

Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top