請問要如何擷取e來做四則運算?

有關於DDE使用、泛VB策略撰寫、績效評估等疑難雜症,都可在此討論。

請問要如何擷取e來做四則運算?

文章kevenpeter 發表於 2010年 6月 19日, 14:03

Imports System.Text
Imports NDde.Client

Public Class MainForm
Private WithEvents client As DdeClient

Private Sub client_Advise(ByVal sender As Object, ByVal e As NDde.Client.DdeAdviseEventArgs) Handles client.Advise

' this subroutine(子程式) runs each time the specified(指定的) DDE Server data item is updated
txtDDEData.Text = e.Text ' put the data received from the server in txtDDEData textbox
displayTextbox.Text = "OnAdvise: " + e.Text + vbNewLine ' update the Status textbox
===>請教各位先進,要如何擷取e來做四則運算?
End Sub

Private Sub client_Disconnected(ByVal sender As Object, ByVal e As NDde.Client.DdeDisconnectedEventArgs) Handles client.Disconnected
' update the Status textbox showing that the server is disconnected
displayTextbox.Text = _
"OnDisconnected: " + _
"IsServerInitiated=" + e.IsServerInitiated.ToString() + " " + _
"IsDisposed=" + e.IsDisposed.ToString()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
displayTextbox.Text = ""
Try
' if this is the first time through then the client object has not been created
' and the following code will throw(丟出) an error - just ignore the error
If client.IsConnected Then client.Disconnect()
Catch
End Try

Try
' Connect to the server. It must be running or an exception will be thrown.
client = New DdeClient("ts", "ks", Me) '(txtDDEServer.Text, txtDDETopic.Text, Me)改
client.Connect()
displayTextbox.Text = "Connected" ' update the Status textbox indicating(表示) that we are connected
' start Advise Loop
client.StartAdvise("txfg0.124", 1, True, 60000) '(txtDDEItem.Text, 1, True, 60000)改
Catch ex As Exception
displayTextbox.Text = ex.Message ' oops - an error occurred - show the cause of the error in the Status textbox
End Try

End Sub
Private Sub OnExecuteComplete(ByVal ar As IAsyncResult)
' this subroutine(子程式) runs when a DDE command is sent using the Asynchronous(非同步的) Execute
' this lets you know that the DDE Command was processed - this code is not used in this example
' instead, we use a Synchronous(同步的) Execute where the command is send and is assumed(假定) to be processed
Static x As Long = 0
x += 1
Try
Dim client As DdeClient = DirectCast(ar.AsyncState, DdeClient)
client.EndExecute(ar)
displayTextBox.Text = "OnExecuteComplete " + x.ToString
Catch e As Exception
displayTextBox.Text = "OnExecuteComplete: " + x.ToString + " " + e.Message
End Try
End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
' Asynchronous(異步的) Execute Operation
'client.BeginExecute(txtCommand.Text, AddressOf OnExecuteComplete, client)

' Synchronous Execute Operation - send the DDE command
client.Execute(txtCommand.Text, 1000)

Catch ex As Exception
displayTextbox.Text = "Command execution failed "
End Try

End Sub



End Class
kevenpeter
 
文章: 2
註冊時間: 2009年 10月 19日, 21:25

Re: 請問要如何擷取e來做四則運算?

文章Keroro 發表於 2010年 6月 22日, 23:17

大大應該須要 val(e.text) 這指令吧,用法自行參閱書本
Keroro
 
文章: 111
註冊時間: 2009年 3月 18日, 23:43


回到 Excel VBA、VB、VB.Net交易平台

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 0 位訪客