Imports System.Text
Imports NDde.Client
'-- connection string format for Sella trading
'-- DDEXT|DR!MINIC000
Public Class MainForm
'--Private WithEvents client As New DdeClient("myapp", "mytopic", Me)
Private WithEvents client As New DdeClient("DDEXT", "DR", Me)
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
btnDisconnect.Enabled = False
btnConnect.Enabled = True
End Sub
Private Sub client_Advise(ByVal sender As Object, ByVal e As NDde.Client.DdeAdviseEventArgs) Handles client.Advise
Select Case e.Item
Case "MINIC070"
txtBid.Text = e.Text
Case "MINIC060"
txtAsk.Text = e.text
Case "MINIC000"
txtLast.Text = e.Text
Case "MINIC007"
txtTime.Text = e.Text
Case "MINIC014"
txtVolume.Text = e.Text
End Select
End Sub
Private Sub client_Disconnected(ByVal sender As Object, ByVal e As NDde.Client.DdeDisconnectedEventArgs) Handles client.Disconnected
displayTextBox.Text = _
"OnDisconnected: " + _
"IsServerInitiated=" + e.IsServerInitiated.ToString() + " " + _
"IsDisposed=" + e.IsDisposed.ToString()
End Sub
Sub BtnConnectClick(sender As Object, e As EventArgs)
btnConnect.Enabled = False
btnDisconnect.Enabled = True
Try
' Connect to the server. It must be running or an exception will be thrown.
client.Connect()
'--Advise Loop Format:
'--client.StartAdvise("myitem", 1, True, 60000)
'--Last Volume: =DDEXT|DR!'MINIC014'
'--Time: =DDEXT|DR!'MINIC007'
'--Bid: =DDEXT|DR!'MINIC060'
'--Ask: =DDEXT|DR!'MINIC070'
'--Last Price: =DDEXT|DR!'MINIC000'
client.StartAdvise("MINIC070", 1, True, 60000)
client.StartAdvise("MINIC060", 1, True, 60000)
client.StartAdvise("MINIC000", 1, True, 60000)
client.StartAdvise("MINIC007", 1, True, 60000)
client.StartAdvise("MINIC014", 1, True, 60000)
Catch ex As Exception
displayTextBox.Text = ex.Message
End Try
End Sub
Sub BtnDisconnectClick(sender As Object, e As EventArgs)
client.Disconnect()
txtBid.Text = ""
txtAsk.Text = ""
txtLast.Text = ""
txtTime.Text = ""
txtVolume.Text = ""
End Sub
End Class