Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Call a C DLL from VB.NET 2003 for the USB-6008 I/O device

We need to work in VB.NET 2003 on the USB-6008. We already have a examples in C# for how to read and output Analog voltage...
We need the following example in VB.NET (not C#). Knowing that we included NIdaqmxbase.h
Thank you.

// Task parameters
int error = 0;
TaskHandle taskHandle = 0;
// Channel parameters
string chan = "Dev1/ai0";
double min = -10.0;
double max = 10.0;

// Timing parameters
System.UInt32 samplesPerChan = 1;

// Data read parameters
double data;
int pointsToRead = 1;
int pointsRead;
double timeout = 1.0;
System.UInt32 reserved;

// the original code made several references to constants that were defined
// in the NIDAQmxBase.h header file. Since we can't use the C header file
// in .NET programming, I had to find the needed values in the header file
// and define them here in the program (below)
int DAQmx_Val_Cfg_Default = -1; // Default
int DAQmx_Val_Volts = 10348; // Volts
System.UInt32 DAQmx_Val_GroupByChannel = 0; // Group by Channel

error = DAQmxBaseCreateTask("", out taskHandle);
error = DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,null);
error = DAQmxBaseStartTask(taskHandle);
error = DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,out data,samplesPerChan,out pointsRead, out reserved);
error = DAQmxBaseStopTask(taskHandle);
error = DAQmxBaseClearTask(taskHandle);

textBox4.Text = Convert.ToString(data);
0 Kudos
Message 1 of 3
(7,431 Views)
gab73

I'm not too familiar with DAQmx Base, so I'm afraid I won't be much help there.

I wanted to point out that there are a few C# to VB .NET translators available on-line. One that I use is at

http://authors.aspalliance.com/aldotnet/examples/translate.aspx

The translation it provides isn't perfect, but it does give a nice starting point.

Hope this helps,

-- Chris
0 Kudos
Message 2 of 3
(7,403 Views)
Hi gab73,

Please check this discussion forum:

Re: How to use a USB-6008 with vb.net

Thanks,
Lesley Y.
0 Kudos
Message 3 of 3
(7,376 Views)