Visual Basic examples: overview

To perform a DDE write from a Visual Basic application to RSLinx Classic, five things must be defined:
  • DDE application name
  • DDE topic name
  • DDE link item
  • DDE link mode
  • DDE data being sent
For example, if a text box is used as the control for the DDE link, the DDE Application|Topic used is defined in the Link Topic text box property. For RSLinx Classic, the application is
RSLinx
and the topic is configured in RSLinx Classic under the DDE menu. If the topic is Testsol, RSLinx|testsol is placed in the Link Topic property. The DDE item is the PLC data table address you are writing to and is defined in the Link Item property of the text box. The data being sent is placed in the text property of the text box. Consequently, if you wanted to write 10 to N7:0, N7:0 is stored as the Link Item and 10 is stored in the Text property. Define the Link Mode property of your control. To perform a write to RSLinx Classic, set the Link Mode to 2 (manual link) in order to establish a link. Perform a Link Poke that sends the value entered in the text property of a text box to RSLinx Classic. Set the Link Mode to 0 (none) in order to close the DDE link.
When writing a block of words from Visual Basic to RSLinx Classic, the following syntax is used: #TAB#TAB#TAB#..., where # is the number that you are sending. If you want to send 1, 2, 3, and 4 to N7:0 to N7:3 from a text box, the Link Item property is N7:0,L4,C4 (L4 meaning block length of 4, C4 means put the data in columns of 4) and the Text property would be the string 1{TAB}2{TAB}3{TAB}4 (defined in Visual Basic as 1 & CHR$(9) & 2 & CHR$(9) & 3 & CHR$(9) & 4 .)
For a Visual Basic application to read from RSLinx Classic, four things must be defined:
  • DDE application name
  • DDE topic name
  • DDE link item
  • DDE link mode
For example, if a label box is used as the control for the DDE link, the DDE Application|Topic being used is defined in the Link Topic property of the label box. For RSLinx Classic, the application is
RSLinx
and the topic is configured in RSLinx Classic under the DDE menu (if the topic is Testsol, then RSLinx|testsol is placed in the Link Topic property). The DDE item is the PLC data table address you are writing to and is defined in the Link Item property of the label box. Consequently, if you wanted to read from N7:0, N7:0 is stored as the Link Item. As the data is read, it is stored in the caption property of the label box.
Define the Link Mode property of your control. When the Link Mode is set to 1, an automatic link is created and data is sent as a hot link. Therefore, there is a continuous link between Visual Basic and RSLinx Classic. When the Link Mode is set to 2, a manual link is established, which opens a DDE link to RSLinx Classic, but no information is read until a Link Request command is performed. Setting the Link Mode to 3 establishes a notify link between RSLinx Classic and Visual Basic. Therefore, whenever the data changes, a Link Notify event occurs, but no information is read until a Link Request command is performed. When the Link Mode is set to 0, there is no DDE link open for that control. This can be used to close an open DDE link.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal