The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for
Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0
SUMMARY
The error message "DDE channel locked" indicates that an attempt is being
made to open a DDE conversation between two objects that are already
engaged in a conversation. However, usually the error message occurs in a
Visual Basic application as a result of a non-Visual Basic DDE Server
application failing to post or send a DDE message Visual Basic is
expecting.
The best overall solution is to alter the DDE server application so that it
correctly sends the appropriate DDE messages.
Both "DDE channel locked" and "Timeout while waiting for DDE response" are
errors that can be trapped in Visual Basic, so you can work around the
problem by performing the following steps:
- Turn on error trapping. For example:
On Local Error GoTo DDEerrhand:
- In your error handling routine, trap error #284 ("DDE channel locked")
and set the LinkTimeout property to 1. This triggers the error message
"Timeout while waiting for DDE response" much quicker.
- Also, in your error handling routine trap error #286 ("Timeout while
waiting for DDE response"), reset the LinkTimeout value, re-establish
the link, and execute a RESUME statement, as in this example:
DDEerrhand:
Select Case Err
Case 284:
OldLinkMode = Text1.LinkMode
OldTimeout = Text1.LinkTimeout
Text1.LinkTimeout = 1
Resume
Case 286:
Text1.LinkTimeout = OldTimeout
Text1.LinkMode = 0
Text1.LinkMode = OldLinkMode
Resume
End Select
MORE INFORMATION
The DDE conversation guidelines set by the Windows Software Development Kit
(SDK) require that Visual Basic sometimes wait for an expected DDE message.
If that message is never correctly sent or posted to Visual Basic, the
following scenario is likely to occur, leading to the error message "DDE
channel locked":
- At some point between when Visual Basic established the conversation and
the conversation terminated, the DDE server application fails to post or
send a message that Visual Basic is expecting as a normal part of the
DDE termination procedure.
- At this point, Visual Basic is in a PeekMessage loop waiting for a
message from the server indicating that the server application has also
terminated the DDE conversation. Because Visual Basic is yielding the
CPU inside the loop, the Visual Basic code continues to execute and the
DDE conversation appears to have terminated normally from the server
side.
- Because Visual Basic is still waiting for the expected DDE message from
the server application, the DDE channel is still open. Any attempt to
reopen the channel (such as setting the LinkMode property for the
control performing the DDE) results in a "DDE channel locked" error.
If no further DDE actions are attempted, you will receive a "Timeout while
waiting for DDE response" error message. The timeout will occur after a
number of milliseconds equal to the communicating control's LinkTimeout
property.