Solved

How to use Events??

Posted on 1998-10-09
2
160 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now