Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

windows runtime error R6025

I'm trying to learn NI DAQ mx, so I've written a very simple aplication to try out some basic functions.
 
When I click the Quit button in my app, I execute the following to make sure all tasks are stopped and cleared
 
Private Sub Command2_Click()
    On Error Resume Next
   
    er = DAQmxStopTask(taskA_in)
    er = DAQmxStopTask(taskA_out)
    er = DAQmxStopTask(taskD_out)
    er = DAQmxStopTask(taskScanA_in)
   
    er = DAQmxClearTask(taskA_in)
    er = DAQmxClearTask(taskA_out)
    er = DAQmxClearTask(taskD_out)
    er = DAQmxClearTask(taskScanA_in)
   
    On Error GoTo 0
   
    End
   
End Sub
 
This "works" as long as I haven't used any of the tasks. If I use any task, when this code executes it gives a run time error R6025 "pure c++ function call" and VB terminates (I am running from within VB6 environment).
 
Any ideas? The program was working until I tried to add a function for scanning A_in (as opposed to single point) and measure the progress with daqmxregistereverynsamplesevent(...)
 
Thanks
0 Kudos
Message 1 of 2
(7,434 Views)

OK, answered my own question.

 

If I created a trask, used it, then stopped and cleared it, then called the above code, the error would crah the program when I tried to stop the task that was used. If I never used the task, the code would execute with no crash.

 

Solution is to keep track of each task that is running and only stop it if is running. Oddly enough, it seems like you can clear the tasks regardless. Like in racing, it's the stopping that kills you!

0 Kudos
Message 2 of 2
(7,430 Views)