Step 2: Basic construction of VB.NET

<< Click to Display Table of Contents >>

Manual > Server Creation Guide > Interface > DDE Interface > DDE connection from VisualBasic.NET >

Step 2: Basic construction of VB.NET

Step 2: Basic construction of VB.NET

This section explains the basic configuration of VB.NET. Please check the details by comparing with the sample.

 

 

hint

In the sample, the DDE related processing is defined in the Common class (Common.vb), and includes processing code for everything from connecting to reading and writing values. The following example shows how to build using the Common class.

 

 

1.Defines the connection process to the DDE server.
 
Initial processing and connection are performed. Initial processing is performed by "SuDdeInit", and connection is performed by "FnDdeConnect".

'------------------------------------------
' DDE Start & Connect
'------------------------------------------
Private Sub btStart_Click(sender As System.Object, e As System.EventArgs) Handles btStart.Click
    Dim vAppName As String = txAppName.Text
    Dim vTopiName As String = txTopiName.Text

    SuDdeInit(txAppName.Text, txTopiName.Text)

    mvConv = FnDdeConnect(vAppName, vTopiName)
    If mvConv = 0 Then
        MessageBox.Show(vAppName & "/" & vTopiName & vbCrLf & "Connect failure!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    btDisConnect.Enabled = True
    btRead.Enabled = True
    btWrite.Enabled = True
    btStart.Enabled = False

End Sub

 

2.Defines the disconnection process to the DDE server.
 
Disconnection is performed using "FnDdeConnectEnd".

'------------------------------------------
' DDE DisConnect
'------------------------------------------
Private Sub btDisConnect_Click(sender As System.Object, e As System.EventArgs) Handles btDisConnect.Click

    FnDdeConnectEnd(mvConv)

    btDisConnect.Enabled = False
    btRead.Enabled = False
    btWrite.Enabled = False
    btStart.Enabled = True

End Sub