Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

VB6 crashes when trying to change power on DIO state using NIDAQmx.

Solved!
Go to solution

When I try to change the power up digital output of a PCI-6220M cardusing VB6 and NIDAQmx software, my VB6 crashes.

 

I've build a VB6 application for the same card to read digital in, analog in and set digital out.  This application works fine.  I just can't change the power up status.

0 Kudos
Message 1 of 3
(3,338 Views)
Solution
Accepted by fonsvanh

Greetings Sir,

 

I have found a post on our discussion forum from a customer who was trying to do the same thing as you and also ran into a VB6 crash. In his case the crash was caused by an incorrect parameter setting when calling his function. 

The first part of the post discusses the correct parameters. The second part of this post does not apply to your setup since your type of card does support changing of the power-up state.

 

Please keep us informed about your progress.

Kind Regards,

Wouter

NI Belgium

Message Edited by demux on 03-10-2009 07:46 AM
0 Kudos
Message 2 of 3
(3,318 Views)

Hello Wouter,

 

thanks for your info.

 

The reason why VB6 crash is indeed caused by an incorrect parameter.

 

 

An example of this command I've found in the C API

 

DAQmxSetDigitalPowerUpStates ("Dev1", "Dev1/do0", DAQmx_Val_High, NULL);

 

In the NI-DAQmx C API Visual Basic 6 Help is mentioned in the frequently asked questions (Examples -- frequently asked questions) that the "NULL" has to be replaced by "Byval 0&" in Visual Basic. 

 

Frequently Asked Questions

How do I pass data to a "reserved" parameter?

A number of NI-DAQmx functions contain parameters that are reserved for future use. In C, you must pass NULL to this parameter. In Visual Basic 6.0, you must pass the number 0 (ByVal 0&).

 

 

 

This works for the other statements I used in the program, but appearantly not for the  DAQmxSetDigitalPowerUpStates.

 

When I replace the "ByVal 0&" by the number "1", the statement works fine.

So my statement that caused the VB6 crash

DAQmxSetDigitalPowerUpStates("Dev1", "Dev1/line8:15", DAQmx_Val_High, ByVal 0&)

was changed to

DAQmxSetDigitalPowerUpStates("Dev1", "Dev1/line8:15", DAQmx_Val_High, 1) which is causing no  errors.

Another strange thing I've noticed, is that when you replace "Byval 0&" by "0", VB6 crashed also.

Krgds,

Alfons Vanhoudt

0 Kudos
Message 3 of 3
(3,291 Views)