03-09-2009 07:21 AM
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.
Solved! Go to Solution.
03-10-2009 07:43 AM - edited 03-10-2009 07:46 AM
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
03-16-2009 03:50 AM
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.
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