Solved

How to use Events??

Posted on 1998-10-09
2
165 Views
Last Modified: 2010-04-30
I am a total newbie to VB Programming, so please bare with me....  I have a program, and when a particular thing occurs, I want an event to be Raised(so that another program knows to do something).  How do I raise an event(that isn't something like onclick().)  Now, how can I have another vb program listen for this event, and carry out some actions if this event is actually raised?
Thanks, hope this makes sense.
0
Comment
Question by:sbishop
2 Comments
 
LVL 2

Expert Comment

by:Veroland
ID: 1439035
It sounds like you want to use something like DDE. Dynamic Data Exchange
0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1439036
sbishop
A event is araised by a component in your (such as a control) program to indicate something happed to it (like click), so you can add code in the event to do what you like when the event happens.  This is because you don't know or don't care what's going on inside the control until the event is happening. You don't not raise an event (so to speek) in your program, because you know exactly what is going on in your program.

What you talking about another program, it is a different story. The 2nd program may not care what is going on in the first, only when the "event" occur.  So what you can do is to make the first program as a component of the 2nd in the form of ActiveX (Control, Dll, EXE).  In that case you can raise an event.
To raise a event, you first tell VB that your control(say) has event using the WithEvent
Example: Private WithEvents myControl As Someobject

then you defined what event:
Public Event ChangeText()

and finally when it's time to raise it, using:RaiseEvent ChangeText


It is a little  complecated. So you may look at the DDE, it is much simpler. But DDE is a deminishing technology and it is not as reliable.

Regards
Dalin

 



0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question