Programming NI-DAQ in Microsoft Visual Basic
Programming NI-DAQ in Microsoft Visual Basic
Basic .NET
Primary Software:
Primary Software Version: 1.0 Service Pack 1
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Multifunction DAQ (MIO)
Problem:
What options do I have when programming NI-DAQ in Visual Basic .NET?
Solution:
Using either the Traditional NI-DAQ or NI-DAQmx driver you can program with NI-DAQ in
Visual Basic .NET. With NI-DAQmx you can use Measurement Studio for Visual Studio which
provides additional tools for use with NI-DAQmx, though Measurement Studio is not required to
use NI-DAQmx in a text-based environment.
Traditional NI-DAQ
National Instruments does not provide native .NET components for Traditional NI-DAQ.
You can use the Traditional NI-DAQ ActiveX controls to perform data acquisition.
The CWDAQ ActiveX control is provided with the Traditional NI-DAQ Driver and does
not require Measurement Studio.
You can create a new VB project and use the ActiveX controls that are installed with
Traditional NI-DAQ. To add the CWDAQ ActiveX Controls to a .NET project, complete
the following steps:
1. Inside a .NET project, select View Toolbox from the pull-down menu.
2. The Toolbox will appear. Right-click in the toolbox and select Add/Remove
Items.
3. The Customize Toolbox will appear. Select the COM Components tab.
4. On this tab, you can select the specific CWDAQ control you want to use and
click OK.
5. The control you selected will now show up in the toolbox, where you can drag
and drop it onto the form.
NI-DAQmx
National Instruments provides a native .NET API for NI-DAQmx. This is available as a
part of the NI-DAQmx driver and does not require Measurement Studio.
If Measurement Studio is installed it will provide support for Visual Studio provides
native .NET class libraries and integration and code generation tools for NI-DAQmx and
Visual Studio. For example, Measurement Studio 7.0 and later adds the DAQ Assistant
for code generation, integrated Visual Studio help, user interface .NET controls, and
project wizards.
Note: If the paths above do not exist, be sure you have .NET support installed for NI-
DAQmx.
For both NI-DAQmx and Measurement Studio examples, sub-folders named vb contain
Visual Basic examples.
Table of Contents
Introduction
National Instruments high-performance data acquisition products include our premier NI-
DAQmx driver, delivering increased performance and productivity in a variety of programming
languages, including C#/Visual Basic .NET (VB .NET), Visual Basic 6.0 (VB 6),
LabWindows/CVI and ANSI C/C++. The following text-based NI-DAQmx examples include
both shipping and additional examples to help shorten your development time. These examples
are divided by programming language and measurement type. Examples without links are
shipping examples, and their locations are indicated under each section. Shipping examples may
not be installed by default; support for C/C++ and/or .NET must be checked at the beginning of
the NI-DAQmx driver installation process.
We offer a number NI-DAQmx examples in C# and Visual Basic .NET (VB .NET). In the
following table, examples that are not linked are shipping examples. Shipping examples are
installed when you install NI-DAQmx and their default location is:
The following is a list of our NI-DAQmx examples for Visual Basic 6.0. The default install
directory is for shipping examples is C:\Documents and Settings\All
Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0.
LabWindows/CVI
ANSI C
The DAQ Assistant is provided when using Measurement Studio or LabWindows/CVI with NI-
DAQmx. The DAQ Assistant is a graphical, interactive guide for configuring, testing, and
acquiring measurement data. With a single click, you can generate code based on your
configuration, making it easier and faster to develop complex operations. Because the DAQ
Assistant is completely menu-driven, the time from setup to first measurement can be drastically
reduced.