?
Solved

using DDE from another application to pass informatio to VB

Posted on 2005-05-04
14
Medium Priority
?
479 Views
Last Modified: 2008-01-09
Hi,

We have the manual of a application, it has DDE feature.

I dont have a clue how does DDE works, kindly assist how does DDE works in theory. (sample program fron VB end would really help)

I'm not sure what language was used in developing the application, but one thing is for sure, we are going to use VB to

query data from that application.

do we need to do anything on the vb side to also turn on DDE? does it need to be run both way? to tranfer data from the application to VB.

How does the client and server works? (since we are going to query data from that application which one is the server?)

It would be best if we could create a sample program from vb, where in we click a button and data from the application is forwarded and viewed on vb. kindly assist how can we achieve.

Thanks.


in the manual there are DDE commands like
DDEExcecute
DDEInitiate
DDERequest

0
Comment
Question by:EdwardPeter
  • 7
  • 5
  • 2
14 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 13925156
Hi EdwardPeter,

It is actually quite simple in VB, to start a simple test, create a VB project, on the form place a single textbox.

Then start excel for example, enter a value in cell A1 of the first sheet.

In your textbox's properties set:

.LinkItem = "R1C1" ' Needs to be R1C1 format not A1
.LinkTopic="Excel|Sheet1"
.LinkMode=1 'Automatic

You should immediately see the value in the textbox even without running the project, if you change the value in excel, it will change in your textbox.

That is it for starters, you have set up a DDE link to another application.

For your third-party application, you need to specify the application and topic in the linktopic property such as "MyApp|MyTopic" and the necessary item(s) in .LinkItem and you then have a dynamic view of the data. You can add a button to capture this information at any time.

Tim Cottee
0
 

Author Comment

by:EdwardPeter
ID: 13925195
TimCottee,

clear and concise, couple of thing though, going to test on the application it self.

which is the server and which is the client ?  using vb to get information from the application.

on the application, in theory, do we need to do something? (program etc)

are these 3 the only commands available on VB ?
.LinkItem

I can see in the manual that it supports client and server,
WM_DDE_ACK
WM_DDE_ADVICE
WM_DDE_DATA
WM_DDE_EXECUTE
etc...

Please kindly give advice how can we make this work. (in theory)

Thanks.
0
 

Author Comment

by:EdwardPeter
ID: 13925205
TimCottee,

I see, sorry for asking to fast.

we don't need anything from the 3rd party. except for the topic and item.

is link mode always the same?

Thanks.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 43

Expert Comment

by:TimCottee
ID: 13925252
EdwardPeter,

The server application is always the one which holds the data initially, in this case it is your third-party application, VB is a client to this application. You could equally use Excel or Word as DDE clients to the application if this was appropriate.

No these aren't the only commands available, however the properties of the text box (.LinkItem,.LinkTopic and .LinkMode) wrap the underlying DDE API calls so that you don't have to get involved in them. There are also some methods for a textbox such as .LinkPoke which allows you to write a value to the server application from a textbox. Again this method wraps the underlying API calls to make it nice and simple.

There are some limitations to the implementation of DDE in VB, however in most cases this is not something that you need to worry about, there is a third-part library that is available that enhances the functionality, however as the creator of this library died a few years ago I am not sure if it is still available.

The WM_DDE_ACK etc are message types that are used with the SendMessage api call to define DDE traffic, you can if you want (though I would strongly advise against it because it is quite nasty) get involved at that low level to build DDE comms yourself. It sounds though that you will not need to do this and the standard functionality should be sufficient.

LinkMode to automatic basically says that every time there is a change in the server, the client will be updated. If you set .LinkMode to 2-Manual, you need to do a .LinkExecute method on the textbox to retrieve the value from the server say on a button click event:

Private Sub cmdGetValues()
Text1.LinkExecute
End Sub

For example, automatic is easy but if your values are not changing that often and you are not looking for a dynamically updated display then using the manual linkmode is perfectly reasonable.

Tim
0
 

Author Comment

by:EdwardPeter
ID: 13925336
Tim,

Your a genius !!!

Sadly I can't seem to find the proper names we need to get this to run..
.LinkItem =
.LinkTopic=


------------------------------please kindly see below
DDE Server Implementation
The DDE Service provides a complete server implementation of DDE. This allows
any external or third-party application to create DDE conversations with the IWSP.
Because of the way commands are used by IWSP, no special programming should
ever be required to enable DDE conversations with other applications.
The server implementation supports the standard DDE messages, which include:
• WM_DDE_ACK
• WM_DDE_ADVISE
• WM_DDE_DATA
• WM_DDE_EXECUTE
• WM_DDE_INITIATE
• WM_DDE_INITIATEACK
• WM_DDE_POKE
• WM_DDE_REQUEST
• WM_DDE_TERMINATE
• WM_DDE_UNADVISE
Both static and advise (hot link) data requests are supported. Actual DDE usage varies
among third-party applications. You should refer to the third-party user manual for
information on how to initiate and execute DDE client conversations with the IWSP
as the server. The application name (or named service) for initiating a DDE conversa
tion with the IWSP is PLUS. The IWSP supports only one topic name: PLUS. The
PLUS topic is used to execute commands or request or poke public data. A complete
list of commands that can be executed and public data that can be requested
or poked using DDE are included within the various sections of this publication.
For example, the commands and data available for the DISP are contained in
“DISP Programming” on page 25-1.

kindly assist on how to approach the 3rd party application.

Thanks.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 13925516
EdwardPeter,

It should be simply
.LinkTopic = "PLUS|PLUS"
.LinkItem is tricky as this depends on the items published by the application, there should be a default item list available if you use .LinkItem="Sysitems" you may get a list of available items (in theory you should as this is a "standard" behaviour but with DDE standards are not always what they seem!)


Tim
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 13925539
are you going to implement dde server to dde client.
I don't think you can use VB to create dde server.
What Tim's explanation is for dde client
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 13925551
By the way, DDE is old protocol that MS supports.
DDE is replaced by COM if you can use COM or even .NET then it is better
0
 

Author Comment

by:EdwardPeter
ID: 13925557
Tim,

Where will we place the list item displayed? how can we forward the lists of items to a listbox on the vb program so that we can choose which data we need?

You make life easy, your simply the BEST!!!

EDDYKT,

We need to a get data from the 3rd party application.

Thanks.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 13925667
EdwardPeter,

Ok, for that you would do something like this:

Create a two textboxes and a listbox on the form.

Set one to get the sysitems (also set .Visible = false because you don't need this to be seen).

In your form_load event fill the listbox like this:

Dim aryItems() As String
aryItems = Split(txtItemList.Text,vbTab)
For intItem = LBound(aryItems) To UBound(aryItems)
    List1.AddItem aryItems(intItem)
Next

This should fill the listbox with the values from the sysitems request.

Then you can have

Private Sub List1_Click()
    txtShowValue.LinkItem = List1.Item(List1.ListIndex) ' Set the item to the currently selected one in the listbox
    txtShowValue.LinkTopic = "PLUS|PLUS"
    txtShowValue.LinkMode = 2
End Sub

This should then show the value for that item in the second text box, selecting different values from the list box will change the item retrieved and displayed.


Tim
0
 

Author Comment

by:EdwardPeter
ID: 13925797
Tim,

When we ran the program, the listbox came up empty.

Do we need to connect to it?

Thanks.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 13925865
EdwardPeter,

I don't have a DDE Server application to test it with here, it may be that the textbox used to get the sysitems values doesn't get the list during the form_load event, you may need to do a .LinkExecute on this in form_load to force it to retrieve the list of items.

Tim
0
 

Author Comment

by:EdwardPeter
ID: 13925891
Tim,

I think this is the missing part, we didn't add the trick on form load?

kindly assist if we are on the right path.

Thanks.
 
>>
LinkItem is tricky as this depends on the items published by the application, there should be a default item list available if you use .LinkItem="Sysitems" you may get a list of available items (in theory you should as this is a "standard" behaviour but with DDE standards are not always what they seem!)
<<

In your form_load event fill the listbox like this:

Dim aryItems() As String
aryItems = Split(txtItemList.Text,vbTab)
For intItem = LBound(aryItems) To UBound(aryItems)
    List1.AddItem aryItems(intItem)
Next
0
 

Author Comment

by:EdwardPeter
ID: 13927903
Tim,

We added request.

works like a charm.

Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question