DDE (Dynamic Data Exchange) with Visual Basic

Getting Started:

DDE works on Text Boxes, Picture Boxes or Labels only. It is a method of transferring the data from any of these controls in an application (Source) into a similar control on another application (Destination). DDE can also be used to send commands from the Destination to the Source using the .LinkExecute method. This enables you to write a VB application to send Macro commands to all the Microsoft Office applications, or to another VB app. If you make two projects and set them both to Source and Destination, then bi-directional chat / automation can be used. On these pages are a Simple DDE Project to get you started, which is so easy I have not bothered to use a file to download, and a more advanced Advanced Source / Destination Project pair which demonstrate the Source and Destination applications, and the methods that can be used. These give you an idea of what can be achieved.

Network DDE works the same way, but you have to set NetDDE shares in the Registry. You can then use the same principles over a LAN. The DDE uses NetBIOS so the network protocols are irrelevant

DDE Properties:


LinkTopic: In VB the name of the Application and the Form e.g. "Project1|Form1"
LinkItem: In VB the name of the control e.g. "Text1"
LinkTimeout: The time allowed to establish a DDE conversation in 10ths Second. Set to 5 secs by default (50). Can be set from 1 to 65536 * 0.1 secs, or to -1 for the maximum timeout (1hr 49mins)
LinkMode:
1 or vbLinkAutomatic - Destination automatically updated
2 or vbLinkManual - Destination uses LinkRequest to ask for an update
3 or vbLinkNotify - Source notifies Destination that data has changed.

DDE Methods:


LinkPoke: Allows Destination to send data to to Source
LinkSend: Picture Box only Sends data from Source to Destination
LinkRequest: Destination asks for update on control's data
LinkExecute: Destination can send command strings to Automate Source

DDE Events:


LinkError: Occurs if there is an error during a DDE conversation. The error number is passed as an argument.
LinkExecute: Occurs when a Destination application has sent a LinkExecute command. Write your code to interpret the commands here.
LinkNotify: Occurs in the Destination when the Source data has been changed and LinkMode is set to 3 - Notify.
LinkOpen: Occurs when a Destination is attempting to create a link.
Link Close: Occurs when a DDE link is closed.


Simple DDE Project
Advanced Source / Destination Project
Network DDE
Homepage