Using Visual Basic as a Client
When creating a VB client for use with the PL/B Automation Server, begin by selecting the References menu item from the Project menu. Find the PL/B Runtime 1.0 Type Library entry and select it. This adds the type library information to your project.
Next, add the following to the General Declarations section of your Visual Basic form:
Now create a button and set the caption property to ‘Start Component’. The button should have the following code:
This code first destroys any previous reference to the PlbProgObj variable. It then makes a connection to the PL/B Automation Server’s application object. Next, it creates a new program object using the application object's CreateProgram method. The program then uses the program object to start the "sampsrv" PL/B component program. The next line of code makes a request to look up "Smith". Finally the program releases the application object from the PlbAppObj variable.
To continue the example program, add a listbox to the form. Add the following code to the PlbProgObj_UserEvent1 event. This will format the event result and place it into the listbox.
Now, add the following code to the Sub PlbProgObj_UserEvent2 event. This code tells the component to exit and places some information in the listbox.
Finally, add the following code to the Sub PlbProgObj_Exit event. This code indicates that the exit event was seen and releases the PlbProgObj variable.
See Also: Automation
![]() |