我已经尝试过这个控制台应用程序并且它正常工作但是当我尝试应用相同的代码来创建winform应用程序时,没有错误,但也没有输出。
这是代码:
控制台
Imports MT4API
Module Module1
Sub Main()
Try
Dim symbol As String = "EURUSD"
Dim dde As New MT4DDE("fxpro")
AddHandler dde.OnQuote, AddressOf MT_OnQuote
dde.Connect()
dde.Subscribe(symbol)
Console.WriteLine("Press any key...")
Console.ReadKey()
dde.Unubscribe(symbol)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
Public Sub MT_OnQuote(ByVal sender As Object, ByVal args As QuoteEventArgs)
Console.WriteLine(args.Symbol & " " & args.Bid & " " & args.Ask)
End Sub
End Module
的WinForm
Imports MT4API
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim symbol As String = "EURUSD"
Dim dde As New MT4DDE("cms")
AddHandler dde.OnQuote, AddressOf Me.MT_OnQuote
dde.Connect()
dde.Subscribe(symbol)
TextBox1.AppendText("Press any key...")
dde.Unubscribe(symbol)
Catch ex As Exception
TextBox1.AppendText(ex.Message)
End Try
End Sub
Public Sub MT_OnQuote(ByVal sender As Object, ByVal args As QuoteEventArgs)
Try
'TextBox1.AppendText(args.Symbol)
TextBox1.Text += args.Symbol & vbCrLf
Catch ex As Exception
TextBox1.Text = TextBox1.Text + ex.Message + vbCrLf
End Try
End Sub
End Class
似乎有什么问题?为什么控制台上的输出没有显示在winform的文本框中。
非常感谢。