Important alert: (current site time 7/16/2013 12:58:08 AM EDT)
 

article

A basic DDE Server that accepts LinkExecute commands

Email
Submitted on: 6/25/2002 9:20:38 PM
By: Chui Tey 
Level: Beginner
User Rating: By 9 Users
Compatibility: VB 5.0, VB 6.0
Views: 30931
 
     Demonstrates how to write a VB DDE Server that accepts DDEExecute command.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				

VB DDE Server

  • Create new VB project and name it Project1.
  • Set Form1.LinkTopic to "SYSTEM" and
  • Set Form1.LinkMode to "1 - Source"
  • Add the following code to the form
Option Explicit
Private Sub Form_LinkExecute(CmdStr As String, Cancel As Integer)
 MsgBox "Received " & CmdStr, vbInformation
 Cancel = False
End Sub 

Run the project

VB DDE Client

We'll now code up a client that calls DDE Execute on the server.

  • Create new VB project and name it Project2.
  • Add a textbox call "Text1"
  • Add a command button called "Command1" and
  • Add the following code to the form
Option Explicit
Private Sub Command1_Click()
 Text1.LinkMode = vbLinkNone
 Text1.LinkTopic = "Project1|SYSTEM"
 Text1.LinkMode = vbLinkManual
 Text1.LinkExecute "Hello World"
 
End Sub

Testing

Run the project.

When the form appears click on the button. Notice that the VB DDE Server has received a string from the client and shown it on a textbox.

Comments

DDE is a mechanism that is supported by a lot of applications. It can only handle simple strings, and is not as flexible or powerful as COM. However, some older applications only support DDE, and it is still necessary to code DDE Servers.

Note on link topic

The link topic by default is the EXE name. However, you can change this in the VBP file, if you have a look at the key TITLE="...", this key can be modified to use a different link topic.


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
8/12/2002 10:47:42 AMtom f.

nice code
(If this comment was disrespectful, please report it.)

 
8/13/2002 2:23:26 AMKillerQ13

Arggg! It's been there all along. I was using ugly window hooking that caused my app to crash half of the time a message was sent. Thanks!
(If this comment was disrespectful, please report it.)

 
5/15/2003 7:27:22 PMSarafraz Singh Johl

WHAT IS DIS DD SERVER? Explain first - cassamine
(If this comment was disrespectful, please report it.)

 
1/15/2004 10:09:37 PMPaoPao

a simple yet interesting code to learn. keep up those good works!
(If this comment was disrespectful, please report it.)

 
3/16/2004 11:51:26 AM

Short and sweet, nice example!!!
(If this comment was disrespectful, please report it.)

 
3/15/2005 6:43:07 AMbombdrop

very nice and stops the need for ugly API calls
(If this comment was disrespectful, please report it.)

 
3/15/2005 6:52:55 AM

Nice Code
(If this comment was disrespectful, please report it.)

 
10/3/2007 10:34:06 PMMike

Hello Chui,

At present, my broker provides me with a DDE interface in Excel that continuously updates stocks that I own with pricing data. I would prefer to use the DDE interface to update fields in my VB program. This should be simple, I would think, but I cannot find any way to do it. Your program seems to be very closely related to my needs, but I can't figure out how to do it. Please email me and I can give you more details. Thank you! Mike
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.