Hi all,

I am creating an addin for excel using visual studio and c++.

i have a calling sub in vba

Public Declare Function calcprob Lib "PA.xll" (ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, ByVal g As Integer, ByVal hsr As Double, ByVal asr As Double, ByVal period As Integer, reactions As Variant, bsr As Variant, bgr As Variant) As Variant

Sub test()
row = calcprob(hscore, ascore, time, 0, periods_min, 2, 2, hsr, asr, return_period, reactions, base_scoring_rates, base_goal_rates)
end sub

the xcalcprob method is called successfully and it runs as its meant to.
the variable 'row' gets filled as expected but when control leaves this sub i get the following error

'Windows has triggered a breakpoint in EXCEL.EXE'
'This may be due to a corruption of the heap, which indicates a bug in EXCEL.exe or any of the dlls it has loaded'

Does anybody know how i can go about finding the solution to this?

thnaks in advance