Solved

How to use Events??

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

856 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