External Interfaces/API |
Example: Using Visual Basic and the MATLAB DDE Server
This example shows a Visual Basic form that contains two text edit controls, TextInput and TextOutput. This code is the TextInput_KeyPress
method.
Sub TextInput_KeyPress(KeyAscii As Integer) rem If the user presses the return key rem in the TextInput control. If KeyAscii = vbKeyReturn then rem Initiate the conversation between the TextInput rem control and MATLAB under the Engine topic. rem Set the item to EngEvalString. TextInput.LinkMode = vbLinkNone TextInput.LinkTopic = "MATLAB|Engine" TextInput.LinkItem = "EngEvalString" TextInput.LinkMode = vbLinkManual rem Get the current string in the TextInput control. rem This text is the command string to send to MATLAB. szCommand = TextInput.Text rem Perform DDE Execute with the command string. TextInput.LinkExecute szCommand TextInput.LinkMode = vbLinkNone rem Initiate the conversation between the TextOutput rem control and MATLAB under the Engine topic. rem Set the item to EngStringResult. TextOutput.LinkMode = vbLinkNone TextOutput.LinkTopic = "MATLAB|Engine" TextOutput.LinkItem = "EngStringResult" TextOutput.LinkMode = vbLinkManual rem Request the string result of the previous EngEvalString rem command. The string ends up in the text field of the rem control TextOutput.text. TextOutput.LinkRequest TextOutput.LinkMode = vbLinkNone End If End Sub
The DDE Name Hierarchy | Using MATLAB as a Client |