User manual

Chapter 2 Fundamentals of Building Windows Applications
NI-DAQ User Manual for PC Compatibles 2-4 ni.com
Creating a Windows Application Using Microsoft
Visual Basic
This section assumes that you will be using the Microsoft Visual Basic
IDE to manage your code development, and that you are familiar with
the IDE.
Developing an NI-DAQ Application
To develop an NI-DAQ application, follow these general steps:
1. Open an existing or new Visual Basic project to manage your
application code.
2. Create files of type
.frm
(form definition and event handling code),
.bas
(Visual Basic generic code module), or
.cls
(Visual Basic class
module) and add them to the project.
3. Include the NI-DAQ include file for Visual Basic,
nidaq32.bas
,
into your project. You may also want to include
nidaqcns.inc
and
nidaqerr.inc
. The NI-DAQ include files for Visual Basic are
located in the
.\Include directory under your NI-DAQ directory.
For Visual Basic 5.0/6.0, you can select the Project»Add Module
menu option, click on the Existing tab, then select the module of your
choice.
Alternatively, you can add a reference to the National Instruments Data
Acquisition Type Library, which is part of the NI-DAQ DLL. In Visual
Basic 5.0/6.0, select the Project»References menu option, and check
National Instruments Data Acquisition Library. If you do not see it
listed there, click on the Browse button and locate
nidaq32.dll
in
your
\Windows\system
or
\Windows\system32
directory.
4. RunyourapplicationbyclickingtheRun button.
Note
In Visual Basic, function declarations have scope globally throughout the project.
In other words, you can define your prototypes in any module. The functions will be
recognized even in other modules.
For information on using the NI-DAQ Visual Basic Custom Controls, see the NI-DAQ
Events in Visual Basic for Windows section in Chapter 3, Software Overview.
Please also refer to the Programming Language Considerations topic in the NI-DAQ
Function Reference Online Help file for more information on using the NI-DAQ functions
in Visual Basic for Windows.