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

communicating between too compiled programs??

Status
Not open for further replies.

Kryzsoccer

Programmer
Oct 15, 2002
85
US
Is there a way for two compiled VB codes to communicate with each other? I would like to be able to use one like a function(able to recieve arguments and return values).
As always all help is apreciated!!! Thanks!
-Chris
 
Good question: I wanna know too!

--Bill
One may not reach the dawn save by the path of the night
--Kahlil Gibran
 
Do they both have to function in their own right? It sounds like you just want to use one program to support another. If this is the case, consider writing an Active X DLL or Active X Exe...
 
Thanks for the quick reply!
Active x sounds like it might work, but I have never used it before.

Would it be possible for you to post some quick examples of how the main program and the active x program could "talk" to each other? Or could you point me to any helpful websites?

As always all help is apreciated!!! Thanks!
-Chris
 
Do a search for DLL,

You have used ActiveX alot, believe me.
Any control that you use on your VB form is an ActiveX Control.

You can create an activeX dll, which will run without any interface, by choosing to create a new project and shoosing activeX dll

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
Alternatively, you could use Winsock. I now love Winsock, it's got to be one of the most powerful controls built into VB.

Code:
Private Sub Form_Load()
Winsock1.RemotePort = 1001  ' or other availabe port
Winsock1.RemoteHost = 127.0.0.1  ' address assigned by default to localhost
Winsock1.Connect
Winsock2.LocalPort = 1002  ' having multiple controls for sending and recieving speeds things up
Winsock2.Listen
End Sub

Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close  ' close Winsock1 if open; not 
' likely but saves errors
Winsock1.Accept requestID
End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim str As String
Winsock2.GetData str
'then do something with str, such as putting it in a public variable, or using 
' Select Case to define a list of accepted commands.
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox &quot;Unable to send data.&quot;, vbOKOnly + vbExclamation, &quot;Error&quot;
End Sub

Private Sub Winsock2_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox &quot;Unable to recieve data.&quot;, vbOKOnly + vbExclamation, &quot;Error&quot;
End Sub

'more code...
Winsock1.SendData data
' you would then have similar code on the other app, but with the ports the other 
' way around.

It's a little long-winded, but I like it.
Crystalinity
 
Thanks for your replies,

Crystalinity:
I was going to give yoour winsock example a try but I recieved an error on the line that has:
Winsock1.RemoteHost = 127.0.0.1 ' address assigned by default to localhost

x508:
After creating an active x dll file how do I call it from my exe file?

Thanks for all your help!!
 
Kryzsoccer - give me an email on m.milan@blueyonder.co.uk and I'll send you some sample code I have written...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top