Example Code

Simple Example Using VB.NET to Call LabVIEW DLLs

Code and Documents


The example program demonstrates calling a DLL created in LabVIEW from a VB.NET application. The DLL is a calculator program that allows the user to perform addition, subtraction, multiplication, division, and modulus functions. The VB.NET application consists of two text boxes for the operands and a series of buttons for the operators. The answer is displayed in the results window.

The compiled DLL exports the function:

double Calculator(double Operand1, double Operand2, unsigned short Operator);

To call this function in your VB.NET application, you must first declare the function by using the following prototype:

Declare Auto Function Calculator Lib "..\LabVIEW\LVCalculator.dll" (ByVal val1 As Double, ByVal val2 As Double, ByVal Op As Integer) As Double

*Special Note*
The VI included was developed in LabVIEW 6.1 to allow for compatibility. The DLL, however, was built and compiled in LabVIEW 7.1. This means in order to run this application, LabVIEW 7.1 Runtime Engine must be installed. This can be downloaded free on our website. A link is provided below.

This documentation is contained in README.txt.

To run this program, unzip all the files, and run the VB.NET executable (NETCallLVDLL.exe). Note that the LabVIEW DLL must reside in the \LabVIEW directory of the application.

Related Links:
LabVIEW 7.1 Run-time Engine for Windows 2000/NT/XP

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.