Calling a LabVIEW VI from Visual Basic through ActiveX
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.
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.
Application Software: LabVIEW Full Development System 6.1
Language(s): LabVIEW, Visual Basic
Reader Comments | Submit a comment »
where is the VI? Would be nice to have a
look at it too...
- firstname.lastname@example.org - Jan 11, 2010
This example code is good. But what if we wanted to reference a single parameter only and not all parameters in the vi?
- Jul 22, 2009