Dynamic data exchange (dde) – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 257

10F. Visual Basic
II. SOFTWARE GUIDES - 10. Driver488/W31
II-242
Personal488 User’s Manual, Rev. 3.0
Dynamic Data Exchange (DDE)
Dynamic Data Exchange (DDE) is a feature built into Microsoft Windows where by unrelated
application programs can communicate.
In test and measurement, there are several potential applications for DDE. For example, a very small
program can be written to collect data for another specialized program to process, like a spreadsheet
program. Programs such as Microsoft Excel have a wide variety of graphics, analysis, and report
writing capabilities. Supplying data to Excel directly from an instrument can be a very powerful
solution to a laboratory application.
This example will explain the concept of DDE from a programmer’s perspective using Visual Basic as
the development environment. Driver488/W31 will be used to collect instrument data that will be
automatically transferred to an unrelated application program.
Application
Data that is transferred from one application to another, first goes through the clipboard. This is
important to know when debugging a DDE application. To see what is being transferred from
application to application at run time, just open the Clipboard in the Windows Program Manager.
Every DDE data transfer requires a Client and a Server; the Client receives the data while the Server
supplies it. Visual Basic has three controls that can act as a client: A picture box, a text box, and a
label. Most controls on a form can act as a source for data, but only a form can act as a server.
Windows provides two kinds of application links: Hot links and cold links. Hot links update the data in
the client application as soon as the data is available on the server. Cold links require the operator to
request that the client be updated. Cold links give more control to the operator as to when the data
transfer takes place.
Let us see how Microsoft Excel and Microsoft Word for Windows set up a DDE link:
1.
If you have them, start them both.
2.
In Word, type in a short string of text.
3.
Select the text, then click the Copy item under the Edit menu.
4.
Bring the Excel spreadsheet into the foreground by clicking on its window.
5.
Select a cell, then click Paste Link under its Edit menu. The link is now complete, and any
changes made in the string in the word processor will be reflected in the spreadsheet cell.
Server Links
Visual Basic provides two methods by which its applications can be linked to other applications:
Design-time and run-time links. A design-time link is performed while in the Visual Basic
development environment. Meanwhile, a run-time link is performed when your Visual Basic program
is running. Run-time links are more flexible than design-time links in that the application which will be
linked does not need to be chosen at design time.
Design-Time Links
To create a design-time link between your application and Microsoft Excel:
1.
Place a text box in your application’s form.
2.
Select the text box by clicking on it with the mouse cursor.
3.
Now go up into the Visual Basic Edit menu and select Copy.
4.
If Excel is not running, start it now.
5.
Select a cell in the Excel spreadsheet, then select Paste Link under the Edit menu. The hot link is
now complete. Anything typed into your application’s text box will also show up in the
spreadsheet cell. This link will be maintained when your application is running.