DAQmx Example Programs for Visual Basic 6.0

Updated Dec 28, 2023

Reported In

Driver

  • NI-DAQmx

Other

  • Visual Basic 6.0

Issue Details

Where are the NI-DAQ™mx examples for Visual Basic 6.0 located? Looking through the examples that installed with NI-DAQmx, I noticed that there are numerous examples written for C, but a very limited number of examples available for Visual Basic 6.0. How can I get access to the full list of DAQmx examples from Visual Basic 6.0. and how do I use the DAQmx library?

Solution

Important Note:


Official NI DAQ Visual Basic 6.0 support has ended with NI-DAQmx 9.9 released in 2014. Hence, the VB 6.0 examples provided with the Microsoft Visual Basic 6.0 Support package are not featured in later NI-DAQmx releases. Starting with NI-DAQmx 14, VB 6.0 support was abandoned for Visual Basic .NET.

Example locations are listed in the following KB: NI-DAQmx Example Locations for LabVIEW and Text-Based in Windows.


To Use the Examples:
  1. Locate a ANSI C example similar to the one you want to create in Visual Basic 6.0. ANSI C examples can be found in the above link, too.
  2. Use a text editor to load the example .c file.
  3. All C examples use a DAQmxErrChk macro. Visual Basic 6.0 examples use a Visual Basic 6.0 module that provides similar error checking. The DAQmxErrChk function is present in the NIDAQmxErrorCheck.bas module in the Shared folder.
  4. Use Visual Basic 6.0 to create a new Visual Basic 6.0 Standard EXE project.
  5. Add a reference to nidaqmx.tlb.
  6. Add NIDAQmxErrorCheck.bas module to your project.
  7. In the .c file, locate all the calls—other than DAQmxErrChk—that are prefixed with DAQmx. These are the calls being made to the NI-DAQmx driver.
  8. Make the same function calls to the driver in your Visual Basic 6.0 program.
  9. In many cases, you can simply copy and paste the code from the C program to the Visual Basic 6.0 project, including the DAQmxErrChk macro, if you have added NIDAQmxErrorCheck.bas to your project. After you copy and paste the code, you must complete the following cleanup items:
    • Remove trailing semicolons.
    • Declare variables that are used by the functions.
    • Replace C constant values with Visual Basic 6.0 enumerations. Refer to the NI-DAQmx C API Visual Basic 6.0 Help for more information on Using Enumeration.
    • Replace any C statements with equivalent Visual Basic 6.0 syntax.

Additional Information

Help Location:

Help can be found in the following location on your computer after installing NI-DAQmx and enabling Microsoft Visual Basic 6.0 Support :
<National Instruments>\NI-DAQ\Documentation


If the NI-DAQmx C API examples are not installed on your machine, you can install them by modifying the installation of NI-DAQmx as described in Can't Find NI-DAQmx Examples for LabWindows™/CVI. Be sure to include the examples listed under Microsoft Visual Basic 6.0 Support when selecting components to install.

To use the type library, you must add it to your project by selecting Project»References and checking the box next to NI DAQmx C API.

In order to use the DAQmx Error checking macro as shown in the shipping examples, you also need to include the module NIDAQmxErrorCheck.bas, which is in one of the following folder locations:

  • <National Instruments>\NI-DAQ\Examples\Visual Basic 6.0\Shared\
  • <Documents and Settings>\All Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Shared
  • <Users>\Public\Public Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Shared

To add the module, select Project»Add Module and browse to the indicated NIDAQmxErrorCheck.bas file.