Discussion:
win32 exception when converting C code to Visual Basic 6.0
(too old to reply)
krstn127
2006-06-02 15:10:10 UTC
Permalink
Hi,
 
I got the following C code working, and am trying to convert it to use in my Visual Basic 6.0 program. I get the following error:

"An unhandled win32 exception occurred in VB6.EXE"
Here is my C Code:
int32       error=0; TaskHandle  taskHandle=0; uInt32      data[8]={5,4,5,4,5,4,5,4}; char        errBuff[2048]={'\0'};
 DAQmxErrChk (DAQmxCreateTask("",&taskHandle)); DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines)); DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"OnBoardClock",300000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000)); DAQmxErrChk (DAQmxWriteDigitalU32(taskHandle,8,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL)); DAQmxErrChk (DAQmxStartTask(taskHandle));
 
In my VB code I have a Public Declare statement for the Write Function:

Public Declare Function DAQmxWriteDigitalU32 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal numSampsPerChan As Long, ByVal autoStart As Long, ByVal timeout As Double, ByVal dataLayout As Long, ByVal writeArray As Long, ByRef sampsPerChanWritten As Long, ByRef reserved As Long) As Long
I put breaks in my VB code and it gets that error when trying to execute the DAQmxWriteDigitalU32 function.
Any Ideas??
krstn127
2006-06-02 18:10:09 UTC
Permalink
I tried using the DAQmxWriteDigitalLines function instead and it gave me:
"Attempted to Write digital data that is not supported"
is there any way around this?
I am using the 6534
Laura F.
2006-06-05 16:40:11 UTC
Permalink
Hello krstn127,
Have you looked at the Digital Output example for VB6?  It installs at C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Digital\Generate Values\Write Dig Chan.  It uses the DAQmxWriteDigitalLines function and works with the NI 6534. 
The error you are experiencing generally indicates that you are attempting to write more or less data than the number of lines you have specified.  I think if you look at the example and compare it to your code, you will be able to find the problem.
Let us know if you have additional questions.
Regards,
Laura

Loading...