|
-
Mar 6th, 2002, 08:38 PM
#1
Thread Starter
Hyperactive Member
DDE help
Option Explicit
Private Conv As DDCDem36.Conversation
Private ConvKey As String
Private AdviseKey As String
Private Sub cbConnect_Click()
If ConvKey <> DDECL1.FailedReturnString Then
Set Conv = Nothing
Call DDECL1.Disconnect(ConvKey)
ConvKey = DDECL1.FailedReturnString
AdviseKey = DDECL1.FailedReturnString
chkAdvise.Value = 0
End If
ConvKey = DDECL1.Connect(txtService.Text, txtTopic.Text)
If ConvKey = DDECL1.FailedReturnString Then
txtData.Text = "The converstion could not be established"
cbItem.Enabled = False
Exit Sub
End If
Set Conv = DDECL1.Conversations(ConvKey)
cbItem.Enabled = True
txtData.Text = "Conversation established"
End Sub
Private Sub cbItem_Click()
Dim DataObj As DDCDem36.DDEData
If Conv Is Nothing Then Exit Sub
Set DataObj = Conv.Request(txtItem.Text, 2000)
If DataObj Is Nothing Then
txtData.Text = "The request for data failed"
Else
txtData.Text = DataObj.DataString
End If
If AdviseKey <> DDECL1.FailedReturnString Then
Call Conv.StopAdviseLoop(AdviseKey, 2000)
End If
AdviseKey = Conv.StartAdviseLoop(txtItem.Text, 2000)
If AdviseKey = DDECL1.FailedReturnString Then
chkAdvise.Value = 0
Exit Sub
End If
chkAdvise.Value = 1
End Sub
Private Sub chkAdvise_Click()
If AdviseKey = DDECL1.FailedReturnString Then
chkAdvise.Value = 0
Else
chkAdvise.Value = 1
End If
End Sub
Private Sub DDECL1_DDEAdvise(ByVal ConvKey As String, Conv As DDCDem36.Conversation, _
ByVal ItemKey As String, Advise As DDCDem36.AdviseLoop, Data As DDCDem36.DDEData)
txtData.Text = Data.DataString
End Sub
Private Sub DDECL1_DDEDisconnect(ByVal ConvKey As String, Conv As DDCDem36.Conversation)
Set Conv = Nothing
ConvKey = DDECL1.FailedReturnString
AdviseKey = DDECL1.FailedReturnString
cbItem.Enabled = False
MsgBox "The server has disconnected the conversation"
End Sub
Private Sub Form_Load()
Call DDECL1.Initialise
AdviseKey = DDECL1.FailedReturnString
ConvKey = DDECL1.FailedReturnString
End Sub
Private Sub Form_Unload(cancel As Integer)
Call DDECL1.Uninitialise
End Sub
i have used the above code to establish a DDE connection with modbus which in turn connects itself to a hardware. I am suppose to write in values to the hardware. I tried using conv.pokeinteger but it failed to accomplish the job. Can anyone pls kindly show me how it is done? i'm completely new to DDE.
THanks.
best regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|