Dynamic Data Exchange

Snoops

   

 
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET
By Dhananjay  Katre, Prashant  Halari, Narayana  Rao  Surapaneni, Manu  Gupta, Meghana  Deshpande

Table of Contents
Chapter 4.   Post-migration Changes


DDE is a way of communicating data between Visual Basic applications and applications such as Microsoft Word and Excel. This method was replaced by the OLE automation technology. Visual Basic 6.0 still supports DDE for ensuring backward compatibility. However, the Visual Basic .NET language does not support DDE. According to Microsoft, all Visual Basic applications that communicate with legacy applications that only support DDE should be maintained in Visual Basic 6.0.

If the upgrade wizard is used to upgrade Visual Basic 6.0 applications that use DDE properties, events, and methods , the upgrade process gives several errors. The upgraded project cannot be compiled in Visual Basic .NET because it does not support DDR. The following DDE- related properties, methods, and events are not supported: LinkItem , LinkMode , LinkTimeOut , LinkTopic , LinkExecute , LinkPoke , LinkRequest , LinkSend , LinkClose , LinkError , LinkExecute , LinkNotify , LinkOpen .

Example 8. An example of DDE in action

The following Visual Basic 6.0 code illustrates a Visual Basic 6.0 application that interacts with an Excel workbook. To run this application, open Excel and type in anything in the first column (a few rows would do). The following code is in the DDE1-VB folder for this chapter:

 graphics/icon01.gif Private Sub Form_Click()     Static Row     Row = Row + 1     Text1.LinkMode = 0     Text1.LinkTopic = "ExcelSheet1"     Text1.LinkItem = "R" & Row & "C1"     Text1.LinkMode = 1  End Sub 

Even though DDE is not supported in Visual Basic .NET, we can simulate the same behavior. In the Visual Basic .NET project, include the COM object Microsoft Excel 9.0 object library. The following equivalent Visual Basic .NET code is in the DDE1-VB.NET-Modified folder for this chapter:

 graphics/icon01.gif Private Sub Form1_Click(ByVal eventSender As _   System.Object, ByVal eventArgs As System.EventArgs)_    Handles MyBase.Click     Dim xlApp As Excel.Application     xlApp = GetObject(, "Excel.Application")     Static Row As Integer     Row = Row + 1     If Not xlApp.Cells(Row, 1).Value Is Nothing Then        Text1.Text = xlApp.Cells(Row, 1).Value.ToString()     End If  End Sub 

These code snippets show how DDE-like functionality can be simulated in Visual Basic .NET.


Snoops

   
Top


Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
ISBN: 131009621
EAN: N/A
Year: 2001
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net