Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

emulate obsolete CWIMAQVision.ParticleCoefficients method

I would like to emulate the obsolete CWIMAQVision ParticleCoefficients method using a wrapper function with repeated calls to CalculateCoefficients.  I am running into problems in how to copy the 1D variant array returned by CalculateCoefficients into the 2D array that ParticleCoefficients is expecting.  I am looking for something like the following:
 
Public Function MyParticleCoefficients( _
                    SourceImage As CWIMAQImage, _
                    ParametersArray As Variant, _
                    ParticlesReport As CWIMAQFullParticleReport, _
                    CoeffecientsArray As Variant _
                    ) As Long
    
    Dim I As Long
    Dim J As Long
    Dim varCoeffsArray As Variant
    
    For I = LBound(ParametersArray) To UBound(ParametersArray)
        ParticleCoeffecients = frmImagProc.Process.CalculateCoefficients(SourceImage, _
            ParametersArray(I), ParticlesReport, varCoeffsArray)
        ' Copy the results to 2D array that was originally passed in
        For J = 0 To ParticlesReport.Count - 1
            'I get an error here saying CoeffecientsArray(I, J) =<Type Mismatch>
            CoeffecientsArray(I, J) = varCoeffsArray(J)
        Next J    
    Next I
End Function
 
Any thoughts would be appreciated.
 
Thanks,
Dave
0 Kudos
Message 1 of 2
(5,689 Views)
Hello Dave,
 
Is there a reason you are emulating the function?  Obsolete functions are still able to be called, they are just not the "recommended" method.
 
It appears that the size of the "CoeffecientsArray" variable is not being set, causing the type to be Variant/Empty.  However, the type of varCoeffsArray is Variant/Single (or similar).
 
You should be able to fix this by setting the size.  I used the following line of code in my quick test:
ReDim CoeffecientsArray(UBound(ParametersArray), ParticlesReport.Count - 1)
Hope this helps out!
 
Best Regards,
 
Jesse D.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 2
(5,681 Views)