Calling a LabVIEW VI from Visual Basic through ActiveX
Overview
This Visual Basic program calls LabVIEW through ActiveX. The program programmatically opens a VI, shows it on the screen (if selected) and sends parameters to the VI. The VI runs and collects the data and displays it in a Visual Basic textbox. The attached Visual Basic program opens and runs an example VI included with LabVIEW.
Before the LabVIEW ActiveX interface can be called in Visual Basic, you must open a reference to the LabVIEW 6.0 type library. You can open a reference by checking the correct references in Visual Basic. Make sure to place a checkmark for LabVIEW 6.0 type library in the Project»References menu in Visual Basic. The attached zip file includes an illustration of this menu.Visual Basic calls the following methods:
Set lvapp = CreateObject("LabVIEW.Application")
Set vi = lvapp.GetVIReference(viPath) 'Load the VI in memory
vi.FPWinOpen = True 'show the front panel
vi.Call(paramNames,paramVals) 'run the VI
lvapp.Quit 'quit LabVIEW
The VI you want to call must have the same number of parameters as the setup in Visual Basic and LabVIEW exposes the parameters by wiring the connector of the VI.
Make sure that VI Server is enabled in LabVIEW. Enable VI Server in the Tools»Options menu by selecting VI Server: Configuration from the pull-down menu. Refer to the LabVIEW Help for more information about ActiveX.
Requirements
Filename: 2112.zip
Software Requirements
Application Software: LabVIEW Full Development System 6.1
Language(s): Visual Basic, LabVIEW
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
