User manual

Chapter 2 Fundamentals of Building Windows Applications
© National Instruments Corporation 2-5 NI-DAQ User Manual for PC Compatibles
Example Programs
You can find some example programs and project files in
.\Examples\VBasic
directory under your NI-DAQ directory.
To load an example program, use one of the Visual Basic project files with
the
.vbp
extension. These are Visual Basic 4.0 projects, which you can
openonlywithVisualBasic4.0orlater.
To load an example project with Visual Basic 4.0 or later, select the menu
option File»Open Project, then select the
.vbp
file of your choice.
Refer to the NI-DAQ Examples Help (Start»Programs»National
Instruments DAQ»NI-DAQ Examples Help) for additional information
regarding NI-DAQ examples.
Special Considerations
Buffer Allocation
Visual Basic 4.0 is quite restrictive when allocating memory. You
allocate memory by declaring an array of the data type with which you
want to work. Visual Basic uses dynamic memory allocation so you can
redimension an array to a variable size during run time. However, arrays
are restricted to being less than 64 KB in total size (this translates to about
32,767 (16-bit) integers, 16,384 (32-bit) long integers, or 8,191 doubles).
To break the 64 KB buffer size barrier, you can use the Windows API
functions
GlobalAlloc()
to allocate buffers larger than 64 KB. After
allocation, you must lock memory with
GlobalLock()
to use a buffer of
memory. You can use the memory handle returned by
GlobalLock()
in
place of the buffer parameter in NI-DAQ API functions that accept buffers
(
Align_DMA_Buffer, DAQ_DB_Transfer, DAQ_Monitor, DAQ_Op,
DAQ_Start, DIG_Block_In, DIG_Block_Out, DIG_DB_Transfer,
GPCTR_Config_Buffer, GPCTR_Read_Buffer, Lab_ISCAN_Op,
Lab_ISCAN_Start, SCAN_Op, SCAN_Start, SCAN_Sequence_Demux,
WFM_DB_Transfer, WFM_Load, WFM_Op
). The NI-DAQ header file
declares the buffer parameter As Any. After using the memory, you must
unlock memory with
GlobalUnlock()
and free it with
GlobalFree()
.
Note
If you allocate memory from
GlobalAlloc()
, you must call
GlobalLock
on the
memory object before passing it to NI-DAQ.