Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
33 ratings:
 2.15 out of 5     Rate this Document

Programming NI-DAQ in Microsoft Visual 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:
When you are using Visual Basic .NET and either the NI-DAQ, Traditional or DAQmx drivers, refer to the table below to determine if you can create a DAQ application. The options are also determined by whether or not you have Measurement Studio installed. You can follow the links on the table itself or use the links at the bottom of the page for more information about options with other languages and environments.
  • Measurement Studio for Visual Studio environments provides a collection of managed .NET and MFC C++ libraries* for advanced analysis, scientific user interface controls and measurement data networking. It also provides code generation and integration tools with Visual Studio. Refer to the Measurement Studio for Visual Studio column if you are developing a NI-DAQ application using Visual Studio and you have Measurement Studio 7.0 or later.

  • Visual Studio .NET only (without Measurement Studio) refers to the development options if you have only Visual Studio .NET and no Measurement Studio packages. This means you use Visual Studio .NET for developing DAQ applications using Visual Basic.
  Measurement Studio for Visual Studio
Visual Studio only
(without Measurement Studio)
Visual Basic .NET Traditional NI-DAQ Possible

Possible

NI-DAQmx Optimal Yes
Optimal: Project wizards, code generation, and configuration tools are provided to accelerate DAQ application development.
Yes: Native components are provided for this purpose and shipping examples are included.
Possible: The component was not designed to work natively in that environment, but it is possible to use these components in the required environment by using wrappers or manual configuration. For example, you can use Runtime Callable Wrappers for accessing ActiveX controls in C# or Visual Basic.NET or by manually setting up a Visual C++ project to use C import libraries. Refer to the link for more information.


Visual Basic .NET with Measurement Studio for Visual Studio
  • Traditional NI-DAQ
    • National Instruments does not provide native .NET libraries for Traditional NI-DAQ. Measurement Studio Support for Visual Studio will not provide you any additional functionality for developing Traditional NI-DAQ applications in Visual Studio.
    • You can use the Traditional NI-DAQ ActiveX controls to perform data acquisition. The ActiveX controls are provided with the Traditional NI-DAQ Driver and do not require Measurement Studio. The CWDAQ control is installed as a part of the Traditional NI-DAQ Driver. Refer to the Visual Basic  .NET without Measurement Studio section for information on how to use the Traditional NI-DAQ ActiveX controls from Visual Basic.
  • NI-DAQmx
    • Measurement Studio 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.
    • The location of examples will depend on the version of Visual Studio and is listed in the following Developer Zone Article: Using NI-DAQmx in Text Based Programming Environments.  The general location is:

      C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET<.NET Framework Version>

      Additional examples using Measurement Studio and NI-DAQmx are available. The location of examples will depend on the version of Visual Studio and all locations are listed in the Measurement Studio help.  The most common location is:

      C:\Documents and Settings\All Users\Documents\National Instruments\MStudioVS2005\DotNET\Examples


      Sub-folders named VB contain Visual Basic examples. These examples install with NI-DAQmx. Measurement Studio is not required to install the class libraries or the examples.
      Note: If the example paths above do not exist, be sure you have .NET support installed for NI-DAQmx for the installer feature tree.


Visual Basic .NET without Measurement Studio
  • 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.
    • Examples: Search for examples on NI Developer Zone. Try searching keywords like c#, csharp, net, daq, or a combination of keywords.
    • If you would like to start coding this scenario from scratch, you can create a new C#  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.
    • The location of examples will depend on the version of Visual Studio and is listed in the following Developer Zone Article: Using NI-DAQmx in Text Based Programming Environments.  The most common location is:

      C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET<.NET Framework Version>

      Sub-folders named VB contain Visual Basic examples. These examples install with NI-DAQmx. Measurement Studio is not required to install the class libraries or the examples.
      Note: If the paths above do not exist, be sure you have .NET support installed for NI-DAQmx.


Related Links:
Developer Zone Tutorial: Text Based NI-DAQmx Data Acquisition Examples
Developer Zone Tutorial: Using NI-DAQmx in Text Based Programming Environments
Developer Zone Examples: NI Developer Zone Results
KnowledgeBase 317742FQ: Programming NI-DAQ and NI-DAQmx in Text-Based Languages using Visual Studio
KnowledgeBase 3146J6FQ: (Legacy)Programming NI-DAQ in Visual Basic 6.0
KnowledgeBase 317BPGW3: (Legacy) Programming NI-DAQ in Visual C++ 6.0
KnowledgeBase 317CP7W3: (Legacy)Programming NI-DAQ in Visual C++ .NET (MFC)
KnowledgeBase 3186P9W3: Programming NI-DAQ in Visual C# .NET
Products and Services: NI Measurement Studio

Attachments:





Report Date: 09/08/2003
Last Updated: 02/21/2013
Document ID: 3178NEFQ

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit