NI Home > Community > NI Discussion Forums
Reply
Member
Hydroworks
Posts: 4
0 Kudos

Error -200077 using DAQmx in VBA

Hi,

I am trying to measure several analog current inputs using a NI9203 module in a compactDAQ 9178 8-slot chassis. I am using DAQmx 9.4 on a Windows 7 x64 system with Excel 2010.

I get a -200077 error when trying to call:

 

DAQmxErrChk DAQmxReadAnalogF64(taskHandle, numSampsPerChannel, 10, fillMode, data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)

 

in my program. I have been trying for ages to get this to work, but always the same error no matter what I do. Extended error info from NI I/O Trace is in the two image files attached.

Help much appreciated. Complete code for the userform also attached.

Regards,

 

James.

 

Member
WillPwr
Posts: 131
0 Kudos

Re: Error -200077 using DAQmx in VBA

Hello, Hydroworks!

 

According to this Developer Zone article: Using NI-DAQmx in Text Based Programming Environments, the DAQmxReadAnalogF64 function requires the sampsPerChanRead to be an Int32. (It's about 2/3 of the way down, the 3rd instance of "sampsPerChanRead" if you use the "find" function on the page). I see from the code you attached that you're currently defining it as a Long (Int64). Try switching the variable definition to Integer, and see if the error persists.

 

If so, let us know!

Will Hilzinger | Switch Product Support Engineer | National Instruments
Member
Hydroworks
Posts: 4
0 Kudos

Re: Error -200077 using DAQmx in VBA

Hi Will NI,

Thanks for your response. The function quick info in the vba editor asks for a LONG (see attached image) and throws a compile error if I try and use a different data type. Any other ideas? Anyway, I thought LONG was 32 bit (4 byte)?

Regards,

 

James.

Member
WillPwr
Posts: 131
0 Kudos

Re: Error -200077 using DAQmx in VBA

Hello, Hydroworks!

 

In some languages Long is 4bytes, but in VBA it's actually 8bytes (which you can verify here). But it looks like that's not the problem here.

 

It looks like you may need to explicitly decalare a value for the sampsPerChanRead, since the code you sent only declares it as a variable (it may dafult to zero, hence the output error you saw). You'll also need to make sure that the samples per channel read isn't greater than the samps per channel value (which you currently have set to 10).

 

Try declaring a value, and see if that fixes the error. If not, let us know!

Will Hilzinger | Switch Product Support Engineer | National Instruments
Member
Hydroworks
Posts: 4
0 Kudos

Re: Error -200077 using DAQmx in VBA

Hello again Will NI, Thanks for clarifying the size of the Long type in VB. Regarding my problem, I am confused about your recommendation. As I understand it, sampsperchanread is an Output from the readanalogf64 function. Anyway, I tried initialising the variable with an arbitrary value after declaring it. The invalid property error persists. Another idea? Thank you for your persistance. Kind regards, James
Member
WillPwr
Posts: 131
0 Kudos

Re: Error -200077 using DAQmx in VBA

Hello, hydroworks!

 

Since you're still seeing the error, we can just check out explicitly what VBA is looking for.

 

This KnowledgeBase: What are the Supported Parameters for NI-DAQmx Functions in Visual Basic?, which explores the same error you're receiving, explains where to find the NIDAQmx.h header file. This will outline which integers your function is looking for, and you can then feed them explicitly.

 

Let me know if this helps!

Will Hilzinger | Switch Product Support Engineer | National Instruments