tags:

views:

63

answers:

2

i have a vb6 code i want to use http://ndde.codeplex.com/ , please help me convert to c#

thanks

Const TOPIC_SENSOR As String = "SeeLane|Sensor"
Const TOPIC_GATE As String = "SeeLane|Gate"
Const TOPIC_PIN As String = "SeeLane|Pin"
Const ITEM_SENSOR_ACTIVATE As String = "Activate"
Const ITEM_GATE_OPEN As String = "Open"
Const ITEM_PIN_ON As String = "On"
Const ITEM_PIN_OFF As String = "Off"

Private Sub Form_Load()
On Error GoTo NO_DDE_SERVER
    lblCar.LinkMode = vbLinkNotify
    lblLaneId.LinkMode = vbLinkManual
    lblName.LinkMode = vbLinkManual
    lblAuthorized.LinkMode = vbLinkManual
    lblFile.LinkMode = vbLinkManual
    lblConfidence.LinkMode = vbLinkManual
    lblType.LinkMode = vbLinkManual
    MsgBox "Ket noi voi thanh cong voi SeeLane !!!"
    Exit Sub
NO_DDE_SERVER:
    MsgBox "Khong the ket noi voi  SeeLane !(Xem chuong trinh co chay khong?)."
    Exit Sub

End Sub


Private Sub lblCar_LinkNotify()
On Error Resume Next

    lblCar.LinkRequest
    lblLaneId.LinkRequest
    lblName.LinkRequest
    lblAuthorized.LinkRequest
    lblFile.LinkRequest
    lblConfidence.LinkRequest
    lblType.LinkRequest
    CheckAuthorized
    lblLaneId.Caption = lblLaneId.Caption + 1
End Sub

Private Sub CheckAuthorized()
Dim i As Integer
i = lblAuthorized.Caption
i = i + 1
If lblAuthorized.Caption = 1 Then
    lblPoke.LinkTopic = TOPIC_GATE
    lblPoke.LinkItem = ITEM_GATE_OPEN
    lblPoke = Chr(lblLaneId.Caption)
    lblPoke.LinkMode = vbLinkManual
    lblPoke.LinkPoke
End If

End Sub
A: 

You can't translate that code to C# because it uses DDE, and C# doesn't support DDE. The whole purpose of that code is to provide a DDE library for people who want to use DDE from C#. Just call the library from C# using COM interop.

MarkJ
A: 

If you download the zip file from project website you will see that there are extensive samples included. It should be easy to see what you need to do if you study the samples and documenation. Basically you will call DdeClient.Request to make a request for data and DdeClient.Poke to send data. However, I have to encourage you to avoid using DDE if at all possible. DDE might as well be dead.

Brian Gideon