Solved

how do I raise an event?

Posted on 2004-09-13
7
177 Views
Last Modified: 2011-10-03
I use VB 6.0   I see that there are multiple places that I have to put code to handle events and
I keep getting it wrong.  I want to do I have a form that has a button.  When that button is clicked,
another program that is running at the same time as the first program catches a "p1_button_in"
event and turns a light on.
0
Comment
Question by:dwcronin
7 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12047788
You can not raise an event that happens in the 1st program in the second program.


However you can use Message API functions, so when that event happen in the 1st program

they send it to the second and second program turns the light on.
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12047801
Another easier ways is that when event happens in the 1st program it writes a flag variable to  a textfile and

seconds program check that files to do some action.
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12047810
if still unclear,
please explain more clearly.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:dwcronin
ID: 12047874
I was trying to avoid something like writing to a file.  That is going to use disk access and I know that is slow.
I am trying to get the second program to respond immediately to the first programs button click.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 125 total points
ID: 12048094
This sample may help you:

Share Data Between Apps Without COM
http://www.thescarms.com/vbasic/PassString.asp
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 12048187
Then Consider writing and readiing from the registry which is very fast.

if you need the code I can supply it here.

0
 
LVL 3

Expert Comment

by:aParser
ID: 12048550
What you're talking about -- I think -- is interprocess communication.  There are many ways to do it, one of the most common is the textfile approach that unknown_routine gave you.

The approach that I used under NT 4.0 is to use mailslots.  The more modern approach is to use Microsoft Messaging.

You could also use callbacks.  It is a slightly more sophisticated approach, but one that requires a fair amount of coding.
http://msdn.microsoft.com/library/en-us/vb98/html/vbsmpCallback.asp?frame=true

You could also do something like store the hWnd of your "lightbulb" program, then when your "click" application starts, you read the hWnd (or title) from whereever you've stored it.  When the user clicks the button in the "click" application, you make the "lightbulb" application the foreground application and use SendKeys to send a key sequence that activates your lightbulb.

You could also look at the SendMessage and PostMessage APIs.  This would be a very low-level approach.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

786 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