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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

With Events from component

Status
Not open for further replies.

calahans

Programmer
Jun 14, 1999
348
0
0
IE
Hi all,<br>
<br>
Just a quick Q re With Events and COM. How do you code an client applaction to wait for an event to come from the COM component? I know you use the raise event in the component, but what do you code in the client app? Is it something like an On Error statement?<br>
<br>
Thanks,<br>
<br>
C
 
You'll need to set a module-level boolean variable in the event procedure and in your calling procedure do something like this:<br>
<br>
Do while not mboolEventRaised<br>
DoEvents<br>
Loop<br>
<br>
You can also add a time-out to it by setting mboolEventRaised to True in the timer's Tick handler.<br>
HTH.<br>
<p> Gene Hughson<br><a href=mailto:active_aggressive_1999@yahoo.com>active_aggressive_1999@yahoo.com</a><br><a href= Aggressive - OO VB with an Attitude</a><br>
 
OR<br>
<br>
In your component, you declare a public Event which you raise from somewhere in the code. <br>
<br>
You declare the variable that represents the component-class at the module level. For example, in the UI tier you declare<br>
<br>
Private WithEvents mobjClass as ComponentClass<br>
<br>
Then select the object's event as you would select Form_Load event. Basically, select mobjClass from the left combobox directly above the code window then select the event from right combobox.<br>
<br>
In the new subroutine, insert any code that you want to run when that event is raised.<br>
<br>
Whenever the event is raised by your component, this routine will be invoked.<br>
<br>
Hope this helps!<br>
<br>

 
Thanks,<br>
<br>
I previously implemented it myself, exactly in the manner you suggested!<br>
<br>
C
 
How do i create a singleton object in VB

HELLLLLLLLLLPPPPPPPPP...PLEASE...........

reply at binith.t@svw.com
 
To catch the event in the client, the object reference must be Dim'd WithEvents. You can then select the event handler in the IDE just like you would with a control. HTH.


Gene Hughson
active_aggressive_1999@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top