Once upon a time, from a galaxy of long ago…. before dot Net, before the sockets, there was DDE… and it was good 🙂
Had to do that intro (LOL), this is a very old technology and very few VB6 programmers would even know this exist at all.
You can Google what this is, but basically, it was a way for 2 distinct VB6 applications to exchange data (no sockets involved).
So at this day and age, is there still a room for this old technology?
Yes! There is! Obviously….otherwise, I wouldn’t be writing this blog, right? 🙂
Use Case
3rd party app and no rights to source code
If you’re dealing with old systems, there might be a situation where a vendor wrote a compiled tool and the only way to interact with it is via DDE. They won’t provide you the source codes and they won’t bother writing a socket layer just so you can interact with it, so there you go — take DDE or leave it.
Rolodex
Rolodex is a good sample app that could be written by a vendor containing a list of their employees and you wanted to have access to that list for your billing department.
So, the vendor agreed and provided you access to the Name and Address only, so you can use them in your billing statement.
This is what the Rolodex app looks like (remember, this is an EXE — not DLL).
So the vendor also gave you the info to connect to it:
application name = rolodexapp
topic name = rolodexform
data source = selectedentry
Okay, great! So how do you connect to it and get the selected item?
Subscriber / Client App
Fire up your Visual Basic IDE and create a new Standard EXE.
- Create a new form (though by default it will give you one, called Form1). You can rename your form or keep it.
- Add a textbox to the form.
- Name this textbox “txtCustomerName”.
- Add a command button to the form.
- Name this button “cmdRolodex”.
At this point, your form should look something like this:
While in design mode, double-click the command button so we can write codes in it.
Enter the following codes within the “cmdRolodex_Click” block:
Shell "..\rolodex\rolodexapp.exe", vbNormalFocus
With Me.txtCustomerName
.LinkTopic = "rolodexapp|rolodexform"
.LinkItem = "selectedentry"
.LinkMode = vbLinkNone
.LinkMode = vbLinkAutomatic
End With
Your code in the IDE should look something like this:
Testing the client app
When you run this client app, and click the button, it will invoke/launch the rolodex executable file (via the Shell command).
Afterwards, it sets the link variables to the information given to us (topic and item).
Lastly, it performs an unlink (in case we called it again while linked), then create an automatic link — meaning, whatever value is on the selected entry will automatically be captured in txtCustomerName control.
Sorry my screen recorder decided not to work on this so I’ll just post a screenshot:
From the rolodex (external app), when you change selection, our client app would automatically capture the new value.
Cool, isn’t it? 🙂
You can probably think of something else to use this, and hopefully you get a better appreciation of how much you can do with VB6.